メインコンテンツにスキップ
プラグインに戻る
@capgo/capacitor-intent-launcher
チュートリアル
@capgo/capacitor-intent-launcher

インテント ランチャー

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

ガイド

意図起動ラッパーに関するチュートリアル

capgo/capacitor-intent-launcherを使用する

Capacitorの意図起動プラグインは、AndroidとiOS両方でAndroidの意図とシステム設定を開くことができます。

インストール

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

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

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

例の使用

startActivityAsync

指定されたアクションの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

iOS設定画面を開きます。

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

パッケージ名でアプリケーションを開きます。

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

フルリファレンス

Using @capgo/capacitor-intent-launcherから続けてください。

Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-intent-launcherを使用している場合 Using @capgo/capacitor-intent-launcherを使用 ダッシュボードとAPIの運用計画を立てるには、 @capgo/capacitor-intent-launcher 実装詳細については @capgo/capacitor-intent-launcher を参照してください。 Getting Started 実装詳細については Getting Started を参照してください。 API Overview 実装詳細については API Overview を参照してください。 Introduction 実装詳細については Introduction を参照してください。 API Keys 実装詳細については API Keys を参照してください。