__CAPGO_KEEP_0__-Startseite
Zurück zu Plugins
@capgo/capacitor-intent-launcher
Tutorial
von github.com/Cap-go

Intent Launcher

Starten Sie Android-Intents, öffnen Sie Systemeinstellungen und interagieren Sie mit anderen Apps über das Intent-System

Richtlinie

Tutorial zum Intent Launcher

Mit @capgo/capacitor-intent-launcher verwenden

Capacitor Intent Launcher-Plugin zum Starten von Android-Intents und Öffnen von Systemeinstellungen auf Android und iOS.

Installieren

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

Was dieses Plugin enthüllt

  • startActivityAsync - Startet eine Android-Aktivität für die angegebene Aktion.
  • openIOSSettings - Öffnet die iOS-Einstellungsseite.
  • openApplication - Öffnet eine Anwendung durch ihren Paketnamen.
  • getApplicationIconAsync - Erhält das Anwendungsicon als base64-codiertes PNG-Bild.

Beispielanwendung

startActivityAsync

Startet eine Android-Aktivität für die angegebene Aktion.

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

Öffnet die iOS-Einstellungen.

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

Öffnet eine Anwendung nach ihrem Paketnamen.

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

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

getApplicationIconAsync

Erhält das Anwendungsicon als base64-codiertes PNG-Bild.

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

Vollständige Referenz