cordovaionic-frameworkcapacitorionic-vuewonderpush

How to set Cordova plugin variables in a Capacitor app?


I am attempting to set up the Wonderpush integration for Ionic using the docs at https://docs.wonderpush.com/docs/mobile-push-notifications-ionic

The instructions say to install the plugin with:

ionic cordova plugin add wonderpush-cordova-sdk --variable CLIENT_ID=YOUR_CLIENT_ID --variable CLIENT_SECRET=YOUR_CLIENT_SECRET --variable SENDER_ID=YOUR_SENDER

...but since my app is a Capacitor app, I must install the plugin with:

npm install wonderpush-cordova-sdk

I can’t figure out how to set the CLIENT_ID, CLIENT_SECRET, and SENDER_ID when installing the plugin this way (there is no “--variable” flag for this command), and I’m getting a runtime error when running the app on my device saying those variables are missing. Do you know how I can populate these values? Thanks in advance!


Solution

  • I was able to find where to put these variables. In capacitor.config.json, I made the following changes to the "cordova": {} element.

    "cordova": {
        "preferences": {
          "WONDERPUSH_CLIENT_ID": "<YOUR-CLIENT-ID>",
          "WONDERPUSH_CLIENT_SECRET": "<YOUR-CLIENT-SECRET>",
          "WONDERPUSH_LOGGING": true,
          "WONDERPUSH_AUTO_INIT": true,
          "WONDERPUSH_REQUIRES_USER_CONSENT": false
        }
      }
    

    Then, I ran ionic cap sync, started the app from the IDE, and success!