Capacitor Plugins

repository·main·Indexed 20 days ago

https://github.com/ionic-team/capacitor-plugins

Official Capacitor plugins maintained by the Ionic team. This collection provides modular plugins to access native device features, including @capacitor/action-sheet for native modals, @capacitor/app-launcher for opening external apps, @capacitor/app for lifecycle and deep link management, and @capacitor/browser for browser integration.

Tokens
59.3K
Snippets
253
Records
300
Agent score
66%

What's inside capacitor-plugins

  1. Configure Push Notification channels on Android

    main

    For Android 8.0 (API 26) and higher, you should use notification channels. The SDK determines the channelId in this order:

    1. The channelId explicitly set in the incoming FCM notification.
    2. The default_notification_channel_id specified in AndroidManifest.xml.
    3. The fallback channel provided by the Firebase SDK.

    Warning: If you use option 1 or 2, you must still create the channel in your code using createChannel(...) with a matching ID. If you fail to do this, the SDK will fallback to the default Firebase channel.

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_channel_id"
        android:value="@string/default_notification_channel_id" />
  2. Control Splash Screen visibility and timing

    main

    The splash screen behavior can be managed via the Capacitor configuration file:

    • Automatic Hiding: By default, the splash screen hides automatically after 500 ms.
    • Manual Hiding: To prevent the splash screen from disappearing before your app is ready, set launchAutoHide to false. You must then call SplashScreen.hide() manually.
    • Fixed Duration: To show the splash screen for a specific amount of time during launch, set launchShowDuration in your Capacitor configuration.
  3. Handle plugin results after app restoration with 'appRestoredResult'

    main

    On Android, if the OS terminates your app while it is running a plugin that requires an external Activity (like the Camera), the result might be lost.

    To prevent this, add a listener for appRestoredResult. When the app is relaunched, this listener will provide the result of the plugin call that was interrupted. This is highly recommended for any Android app using plugins that rely on external Activities.

    App.addListener('appRestoredResult', (event) => {
      if (event.pluginId === 'Camera' && event.success) {
        console.log('Restored camera photo:', event.data);
      } else if (event.error) {
        console.error('Plugin call failed:', event.error.message);
      }
    });
  4. Understand InterruptionLevel (iOS)

    main

    The InterruptionLevel determines the priority and delivery timing of a notification on iOS.

    • active: Immediate presentation, lights up screen, plays sound.
    • critical: Immediate presentation, lights up screen, bypasses mute switch. Requires Critical Alerts entitlement.
    • passive: Added to notification list without lighting screen or playing sound.
    • timeSensitive: Immediate presentation, lights up screen, plays sound, and breaks through system notification controls. Requires Time Sensitive Notifications capability.
    'active' | 'critical' | 'passive' | 'timeSensitive'
  5. Silent Push Notifications / Data-only Notifications

    main

    iOS

    This plugin does not support iOS Silent Push (Remote Notifications). You must use native code solutions for background updates.

    Android

    This plugin supports data-only notifications, but pushNotificationReceived will not be called if the app has been killed. To handle notifications when the app is killed, you must implement a custom service that extends FirebaseMessagingService.

  6. Configure Android file sharing permissions

    main
    By default, Capacitor apps only allow sharing files from the caches folder on Android. To make other Android folders shareable, you must add them to the android/app/src/main/res/xml/file_paths.xml file. Refer to the FileProvider documentation for available locations.