Passer au contenu principal
Retour aux plugins
@capgo/capacitor-intent-launcher
Tutoriel
@capgo/capacitor-intent-launcher

Intent Launcher

Lancez les intentions Android, ouvrez les paramètres système et interagissez avec d'autres applications à l'aide du système d'intentions

Guide

Tutoriel sur l'Intent Launcher

Tester sur appareil

Téléchargez l'application Capgo, puis scannez le code QR code.

Lien QR de prévisualisation du plugin d'ouverture d'intent code

Utilisation de @capgo/capacitor-intent-launcher

Capacitor Plugin d'ouverture d'intent pour lancer les intents Android et ouvrir les paramètres système sur Android et iOS.

Installer

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

Ce que ce plugin expose

  • startActivityAsync - Démarre une activité Android pour l'action spécifiée.
  • openIOSSettings - Ouvre l'écran de paramètres iOS.
  • openApplication - Ouvre une application par son nom de package.
  • getApplicationIconAsync - Récupère l'icône de l'application sous forme de chaîne base64 PNG encodée.

Exemple d'utilisation

startActivityAsync

Démarre une activité Android pour l'action spécifiée.

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

Ouvre l'écran de paramètres 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

Ouvre une application en fonction de son nom de package.

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

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

getApplicationIconAsync

Récupère l'icône de l'application sous forme de chaîne de base64 PNG encodée.

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

Référence complète

Continuez à partir de l'utilisation de @capgo/capacitor-intent-launcher

Si vous utilisez L'utilisation de @capgo/capacitor-intent-launcher pour planifier le tableau de bord et les opérations API, connectez-le avec @capgo/capacitor-intent-launcher pour les détails d'implémentation dans @capgo/capacitor-intent-launcher, Démarrage pour les détails d'implémentation dans Démarrage, API Vue d'ensemble pour les détails d'implémentation dans API Vue d'ensemble, Introduction pour les détails d'implémentation dans Introduction, et API Clés for the implementation detail in API Keys.