Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
URLScheme.SetDefaultHandler
Sets the user's preferred handler for the specified URL scheme to point to the current application.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
URLScheme | 2.0 | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |
(old name: SetDefaultHandlerForURLScheme)
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
scheme | The schema name. | "http", "https", "mailto" or something else | |
bundleID | Available in MBS FileMaker Plugin 7.5 or newer. The bundle ID for the application. If empty, we use the one of the current application. |
Optional |
Result
Returns OK or an error message on failure.
Description
Sets the user's preferred handler for the specified URL scheme to point to the current application.It's probably best to ask the user's permission before changing their default browser!
With plugin version 5.3 this works on Windows if FileMaker or runtime is launched as admin. Still that may not help much as when FileMaker is launched with URL, it shows an error message.
Examples
Set runtime to be default email application:
MBS("URLScheme.SetDefaultHandler"; "mailto")
Register URL scheme for runtime:
If [MBS("IsMacOSX") and MBS("IsRuntime")]
# make us the default app for FMP URL scheme
Set Variable [$vorher; Value:MBS( "URLScheme.GetDefaultHandler"; "fmp" )]
Set Variable [$setResult; Value:MBS( "URLScheme.SetDefaultHandler"; "fmp" )]
Set Variable [$r; Value:MBS( "URLScheme.GetDefaultHandler"; "fmp" )]
# okay or failure?
If [$r ≠ "com.filemaker.client.runtime12.Test"]
# Register by using lsregister tool on command line
Set Variable [$r; Value:MBS( "RunTask.NewTask" )]
Set Variable [$r; Value:MBS( "RunTask.SetLaunchPath"; "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister")]
Set Variable [$path; Value:MBS( "App.GetProcessPath" )]
Set Variable [$r; Value:MBS( "RunTask.SetArguments"; "-f"; $path /*"/Applications/Test/Test.app" */)]
Set Variable [$r; Value:MBS( "RunTask.Launch")]
# wait until finished
Loop
Pause/Resume Script [Duration (seconds): ,1]
Exit Loop If [MBS("RunTask.IsRunning") ≠ 1]
End Loop
# Check again
Set Variable [$setResult; Value:MBS( "URLScheme.SetDefaultHandler"; "fmp" )]
Set Variable [$r; Value:MBS( "URLScheme.GetDefaultHandler"; "fmp" )]
End If
End If
Select this FileMaker Pro to receive fmp URLs:
MBS("URLScheme.SetDefaultHandler"; "fmp")
Set fmp handler to FMP Advanced:
MBS( "URLScheme.SetDefaultHandler"; "fmp"; "com.filemaker.client.advanced12")
See also
- App.GetProcessPath
- IsRuntime
- RunTask.IsRunning
- RunTask.Launch
- RunTask.NewTask
- RunTask.SetArguments
- RunTask.SetLaunchPath
- URLScheme.GetDefaultHandler
Release notes
- Version 7.5
- Added parameter bundleID to URLScheme.SetDefaultHandler function.
Blog Entries
- MBS FileMaker Plugin, version 7.5pr7
- MBS FileMaker Plugin, version 5.3pr3
- MBS Filemaker Plugin, version 3.0pr6
This function checks for a license.
Created 18th August 2014, last changed 22nd October 2018