__CAPGO_SKIP__ __CAPGO_TO__ __CAPGO_MAIN__ __CAPGO_CONTENT__
プラグインに戻る
@capgo/capacitor-intent-launcher
チュートリアル
github.com/Cap-go による

Intent Launcher

Android インテントを起動、システム設定を開き、他のアプリと相互作用するには、Intent システムを使用します。

ガイド

意図ランチャーに関するチュートリアル

意図ランチャーを使用するには @capgo/capacitor-intent-launcher

Capacitor インテントランチャープラグイン: Android インテントの起動と Android、iOS のシステム設定の開き方

インストール

bun add @capgo/capacitor-intent-launcher
bunx cap sync

このプラグインが公開するもの

  • startActivityAsync - 指定されたアクションの Android アクティビティを起動します。
  • openIOSSettings - iOS の設定画面を開きます。
  • openApplication - パッケージ名でアプリケーションを開きます。
  • getApplicationIconAsync - __CAPGO_KEEP_0__ を base64 でエンコードした PNG 画像の文字列として取得します。

使用例

startActivityAsync

__CAPGO_KEEP_0__ アクションを指定して Android アクティビティを開始します。

import { IntentLauncher } 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

__CAPGO_KEEP_0__ の設定画面を開きます。

import { IntentLauncher } 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

__CAPGO_KEEP_0__ をパッケージ名で開きます。

import { IntentLauncher } from '@capgo/capacitor-intent-launcher';

// Open Gmail app
await IntentLauncher.openApplication({ packageName: 'com.google.android.gm' });

getApplicationIconAsync

__CAPGO_KEEP_0__ を 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;
}

完全なリファレンス