canLaunchApp
Description
Reports through a callback whether an external app can be launched with a URL scheme.
The result comes back asynchronously: the first argument of the callback function receives true (can launch) or false (cannot). If URL parsing fails or an exception occurs, it also passes false.
Parameters
| Parameter | Type | Description |
|---|---|---|
| urlScheme | String | URL or URL scheme to check (for example, "kakaotalk://", "mailto:", "https://...") |
| callback | JSFunction | Callback function that receives the result. Takes a single bool argument |
Returns
void (the result arrives through callback)
Notes
- The result is asynchronous. Use the callback pattern rather than
await. - If the app isn't installed on the device, it returns
false. - On Android, querying a specific URL scheme requires a
<queries>entry inAndroidManifest.xml. - On iOS, the scheme must be listed in
LSApplicationQueriesSchemesinInfo.plist. - A URL parsing error or an exception always passes
false.
Example
// Branch after checking whether KakaoTalk is installed
$app.canLaunchApp("kakaotalk://", function(ok) {
if (ok) {
$app.openUrl("kakaotalk://");
} else {
$vm.showToastMessage("error", "카카오톡이 설치되어 있지 않습니다.", 3000);
}
});
// Check the email app
$app.canLaunchApp("mailto:", function(ok) {
$log.i("이메일 앱 사용 가능:", ok);
});
Related
$app.openUrl(urlScheme)— Launch an external app with a URL scheme$app.openExternalBrowser(url)— Open a URL in an external browser