Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

URLScheme.SetDefaultHandler

Sets the user's preferred handler for the specified URL scheme to point to the current application.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
URLScheme 2.0 Yes No No No No

MBS( "URLScheme.SetDefaultHandler"; scheme { ; bundleID } )

(old name: SetDefaultHandlerForURLScheme)

Parameters

Parameter Description Example value
scheme The schema name. "http", "https", "mailto" or something else
bundleID Optional
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.

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


URLScheme.InstallURLEventHandler   -   USB.Count

Feedback: Report problem or ask question.




Links
MBS Xojo tutorial videos