@capgo/capacitor-intent-launcherを使用
CapacitorはAndroidのインテントを起動し、AndroidとiOS両方でシステム設定を開くAndroidとiOS用のインテントランチャープラグイン
インストール
bun add @capgo/capacitor-intent-launcher
bunx cap sync
bunx cap sync プラグインのネイティブcodeをプロジェクトにコピーします。プラグインのアップグレード後は再度実行してください。
インポート
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
APIの概要
| 方法 | 概要 |
|---|---|
startActivityAsync |
指定されたアクションに対してAndroidアクティビティを開始します。 |
openIOSSettings |
iOS設定画面を開きます。 |
openApplication |
パッケージ名でアプリケーションを開きます。 |
getApplicationIconAsync |
アプリケーションアイコンをbase64エンコードされたPNG文字列として取得します。 |
例
startActivityAsync()
指定されたアクションに対してAndroidアクティビティを開始します。
import { IntentLauncher, ActivityAction } from '@capgo/capacitor-intent-launcher';
// Open location settings
const result = await IntentLauncher.startActivityAsync({
action: ActivityAction.LOCATION_SOURCE_SETTINGS
});
// Open a specific app settings
const result = await IntentLauncher.startActivityAsync({
action: ActivityAction.APPLICATION_DETAILS_SETTINGS,
data: 'package:com.example.app'
});
openIOSSettings()
iOS設定画面を開きます。
import { IntentLauncher, IOSSettings } from '@capgo/capacitor-intent-launcher';
// Open app settings (recommended - officially supported by Apple)
await IntentLauncher.openIOSSettings({ option: IOSSettings.App });
// Open WiFi settings (may not work in all iOS versions)
await IntentLauncher.openIOSSettings({ option: IOSSettings.WiFi });
openApplication()
パッケージ名でアプリケーションを開きます。
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
// Open Gmail app
await IntentLauncher.openApplication({ packageName: 'com.google.android.gm' });
getApplicationIconAsync()
アプリケーションアイコンをbase64エンコードされたPNG文字列として取得します。
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
const { icon } = await IntentLauncher.getApplicationIconAsync({
packageName: 'com.google.android.gm'
});
if (icon) {
const img = document.createElement('img');
img.src = icon;
}
context
@capgo/capacitor-intent-launcherを継続して使用してください。
Capacitor インテント ランチャーを使用している場合 @Capacitor-capgo/capacitor-intent-launcher 計画ダッシュボードとAPIの運用を、接続する @capgo/capacitor-intent-launcher Capacitor の実装詳細については @capgo/capacitor-intent-launcher に関するものです。 Capacitor インテント ランチャーを使用して Capacitor インテント ランチャーを使用して API Overview for the API の実装詳細について 概要 概要の実装詳細について API キー API キーの実装詳細について