Type Function Library system.* Return value Boolean Revision Release 2024.3703 Keywords system, canOpenURL, URL See also system.openURL()
Returns a boolean value confirming whether a URL can be opened via system.openURL().
true
if the URL can be opened.false
if the URL is malformed or if there is no app to handle the URL’s scheme. Also returns false
on iOS 9.0+ or tvOS if the URL is not listed in LSApplicationQueriesSchemes
(see below).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" }, }, }, }
This does not check the URL for validity — it simply checks if there is an application associated with a URL scheme.
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 (see above). If the URL scheme is not specified within LSApplicationQueriesSchemes
, iOS will output an error message to the system console. For more information about iOS and tvOS aspects, see here.
system.canOpenURL( url )
String. The URL.
local url = "fb://feed" if ( system.canOpenURL( url ) ) then system.openURL( url ) else print( "WARNING: Facebook app is not installed!" ) end