Anleitung
Intent Launcher in Capacitor nutzen
Mit @capgo/capacitor-intent-launcher
Capacitor Intent Launcher Plugin zum Starten von Android Intents und zum Öffnen von Systemeinstellungen auf Android und iOS.
Installieren
bun add @capgo/capacitor-intent-launcher
bunx cap sync
bunx cap sync kopiert den nativen code des Plugins in deine nativen Projekte. Nach jedem Plugin-Upgrade erneut ausführen.
Importieren
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
API auf einen Blick
| Methode | Beschreibung |
|---|---|
startActivityAsync |
Startet eine Android-Activity für die angegebene Action. |
openIOSSettings |
Öffnet den iOS-Einstellungsbildschirm. |
openApplication |
Öffnet eine App anhand ihres Package-Namens. |
getApplicationIconAsync |
Ruft das App-Icon als base64-kodierten PNG-String ab. |
Beispiele
startActivityAsync()
Startet eine Android-Activity für die angegebene Action.
import { IntentLauncher, ActivityAction } 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 den iOS-Einstellungsbildschirm.
import { IntentLauncher, IOSSettings } 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 App anhand ihres Package-Namens.
import { IntentLauncher } from '@capgo/capacitor-intent-launcher';
// Open Gmail app
await IntentLauncher.openApplication({ packageName: 'com.google.android.gm' });
getApplicationIconAsync()
Ruft das App-Icon als base64-kodierten PNG-String ab.
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
Weiter mit der Nutzung von @capgo/capacitor-intent-launcher
Wenn du es nutzt Nutzung von @capgo/capacitor-intent-launcher um Dashboard- und API-Operationen zu planen, verbinde es mit @capgo/capacitor-intent-launcher für die Implementierungsdetails in @capgo/capacitor-intent-launcher, Erste Schritte für die Implementierungsdetails in Erste Schritte, API Übersicht für Details zur Implementierung im API Overview, Einführung für die Implementierungsdetails in der Einleitung und API Schlüssel für die Implementierungsdetails in den API Keys.