system.canOpenURL()

Type Function
Library system.*
Return value Boolean
Revision Release 2022.3683
Keywords system, canOpenURL, URL
See also system.openURL()

Overview

Returns a boolean value confirming whether a URL can be opened via system.openURL().

Note

If you are deploying the app for iOS 9.0+ or tvOS, you must specify all of the associated URL schemes via the LSApplicationQueriesSchemes key within the plist table of build.settings. For instance, the following addition will allow the app to check if Facebook and Instagram URLs can be opened:

settings =
{
    iphone =
    {
        plist =
        {
            LSApplicationQueriesSchemes = { "fb", "instagram" },
        },
    },
}

Gotchas

Syntax

system.canOpenURL( url )
url (required)

String. The URL.

Example

Check for Facebook App
local url = "fb://feed"

if ( system.canOpenURL( url ) ) then
    system.openURL( url )
else
    print( "WARNING: Facebook app is not installed!" )
end