@napacitor/app-launcher
App launcher plugin wrapping the .NET MAUI Launcher and Map APIs: open other apps, URLs, and the system map.
Installation
To use npm:
npm install @napacitor/app-launcher
To use yarn:
yarn add @napacitor/app-launcher
Sync native files:
npx nap sync
Usage
import { AppLauncher } from '@napacitor/app-launcher';
// Open a URL
await AppLauncher.openUrl({ url: 'https://example.com' });
// Check whether the URL can be handled
const { canOpen } = await AppLauncher.canOpenUrl({ url: 'tel:1234567890' });
// Open an app by package name
await AppLauncher.openApp({ appId: 'com.example.app' });
// Check whether a specific app is installed
const { canOpen: appInstalled } = await AppLauncher.canOpenApp({ appId: 'com.example.app' });
// Open the system map
await AppLauncher.openMap({
latitude: 39.9042,
longitude: 116.4074,
label: 'Beijing',
navigationMode: 'driving',
});
How It Works
Wraps the .NET MAUI Launcher.Default.OpenAsync / CanOpenAsync and Map.Default.OpenAsync facades. openApp / canOpenApp build a URI in the form <appId>:// and go through Launcher; openMap maps label to MapLaunchOptions.Name and navigationMode to NavigationMode (driving / walking / transit, anything else is None).
Permissions
Android
No additional configuration required. openUrl supports http/https/mailto/tel/geo and other protocols.
iOS
No additional configuration required. To detect whether third-party app custom schemes can be opened, declare LSApplicationQueriesSchemes in Info.plist (subject to iOS query limits).
Windows
No additional configuration required.
API
openUrl(options)
Opens a URL (handled by the system browser or the corresponding app). The URL must be a valid absolute address, otherwise INVALID_ARGUMENTS is thrown; opening is still attempted when the platform reports it cannot handle the URL (detection is unreliable on some platforms).
| Param | Type |
|---|---|
options | OpenUrlOptions |
Returns: Promise<void>
canOpenUrl(options)
Checks whether the current platform can handle the URL (returns false when the URL is invalid).
| Param | Type |
|---|---|
options | OpenUrlOptions |
Returns: Promise<CanOpenUrlResult>
openApp(options)
Opens an app by package name / app ID (tries <appId>://; throws UNSUPPORTED when the platform cannot handle it).
| Param | Type |
|---|---|
options | OpenAppOptions |
Returns: Promise<void>
canOpenApp(options)
Checks whether a specific app is installed (returns false when detection fails).
| Param | Type |
|---|---|
options | OpenAppOptions |
Returns: Promise<CanOpenAppResult>
openMap(options)
Opens the system map positioned at the given coordinates.
| Param | Type |
|---|---|
options | OpenMapOptions |
Returns: Promise<void>
Interfaces
OpenUrlOptions
| Prop | Type | Description |
|---|---|---|
url | string | URL to open (supports http/https/mailto/tel/geo and other protocols). |
OpenAppOptions
| Prop | Type | Description |
|---|---|---|
appId | string | Android package name / iOS Bundle ID / Windows app protocol. |
CanOpenUrlResult
| Prop | Type | Description |
|---|---|---|
canOpen | boolean | Whether the current platform can handle the URL. |
CanOpenAppResult
| Prop | Type | Description |
|---|---|---|
canOpen | boolean | Whether the app is installed on the current platform. |
OpenMapOptions
| Prop | Type | Description |
|---|---|---|
latitude | number | Latitude. |
longitude | number | Longitude. |
label | string | Map label (optional, maps to MapLaunchOptions.Name). |
navigationMode | string | Navigation mode: driving / walking / transit (optional, only partially supported; anything else is treated as None). |