Integrate the MobilePush Cordova Plugin with Capacitor or Ionic Apps

Use the MobilePush Cordova Plugin to integrate the MobilePush SDK into your Ionic and Capacitor applications. For detailed installation and setup instructions, see the Cordova Plugin documentation.

This article describes the steps necessary to modify configurations and manage platform-specific setups for Android and iOS apps to effectively adapt the Cordova Plugin to Ionic and Capacitor environments.

To integrate Capacitor or Ionic apps with MobilePush, configure the Cordova plugin by modifying your application's configuration file.

For Ionic apps, modify the capacitor.config.ts file and add preferences under cordova, as shown in the following example.

For Capacitor apps, modify the capacitor.config.json file and add preferences under cordova, as shown in the following example.

You must carry out these steps each time you add the platform to your Capacitor application.

Copy the google-services.json file into the YOUR_APP/android/app/ directory.

  1. Enable push notifications in your target’s Capabilities settings in Xcode by clicking + Capability and then selecting Push Notifications.

    Enabling Push on iOS Apps

  2. Enable iOS push notifications by adding the following code in AppDelegate.

    Additionally, add the following code to the end of the AppDelegate.swift file.

If you're using TypeScript, declare the plugin before calling the APIs as shown in the following example.

For detailed API references, see the Cordova Plugin API Reference.