跳过主要内容
返回插件
@capgo/capacitor-intent-launcher
教程
@capgo/capacitor-intent-launcher

意图启动器

使用意图系统启动安卓意图、打开系统设置以及与其他应用进行交互

指南

意图启动器教程

在设备上测试

下载Capgo应用程序,然后扫描code中的二维码

意图启动器插件预览二维码code

使用@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;
}

全局参考

继续使用 @capgo/capacitor-intent-launcher

如果您正在使用 使用 @capgo/capacitor-intent-launcher 来规划仪表板和 API 操作,连接它与 @capgo/capacitor-intent-launcher 为 @capgo/capacitor-intent-launcher 的实现细节 开始使用 为开始使用的实现细节 API概述 为API概述的实现细节 介绍 为介绍的实现细节, 和 API密钥 为API密钥的实现细节