@capgo/capacitor-intent-launcher の使用
Android と iOS の両方で Android の intent を起動し、システム設定を開くための Capacitor Intent Launcher プラグイン。
インストール
bun add @capgo/capacitor-intent-launcher
bunx cap sync
bunx cap sync プラグインのネイティブcodeをネイティブプロジェクトにコピーします。プラグインをアップグレードするたびに再度実行してください。
インポート
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
API の概要
| メソッド | 説明 |
|---|---|
startActivityAsync |
指定したアクションで Android の Activity を開始します。 |
openIOSSettings |
iOS の設定画面を開きます。 |
openApplication |
パッケージ名を指定してアプリケーションを開きます。 |
getApplicationIconAsync |
アプリケーションのアイコンを base64 エンコードされた PNG 文字列として取得します。 |
例
startActivityAsync()
指定したアクションで Android の Activity を開始します。
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;
}
完全なリファレンス
@capgo/capacitor-intent-launcher の使用から続けます
使用している場合 @capgo/capacitor-intent-launcher の使用 ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-intent-launcher @capgo/capacitor-intent-launcher の実装詳細については、 スタートガイド スタートガイドの実装詳細については、 API の概要 「API の概要」の実装の詳細については、 はじめに はじめにの実装詳細、および API キー API Keys の実装詳細については、