Push Notifications are messages that pop up on mobile devices. App publishers can send them at any time; even if the recipients aren’t currently engaging with the app or using their devices.
Before continuing, please ensure that you have added the WebEngage SDK to your app.
Android (FCM Integration)
Step 1: Add the following plugin to your Cordova project.
cordova plugin add https://github.com/WebEngage/cordova-plugin-android-fcm.git --fetch
Step 2: Save the google-services.json
file in the root of your project directory.
- Follow the steps under Android FCM Documentation to get the
google-services.json
file from your Firebase Cloud account.
Step 3: Update FCM token on app launch.
- Send FCM token to WebEngage SDK in your
wwww/js/index.js
file.
var app = {
...
onDeviceReady: function() {
...
androidfcm.updateToken();
}
}
- Run and test push notifications from WebEngage dashboard on your Android app.
And you're good to go!
GCM to FCM Migration
Step 1: Follow the FCM Integration steps.
Step 2: Remove the following from your config.xml file
, under Android Platform tag.
<widget ... xmlns:android="http://schemas.android.com/apk/res/android">
...
<platform name="android">
<config-file parent="/manifest/application" target="AndroidManifest.xml">
...
<!-- Remove these meta-data and receiver tags -->
<!--
<meta-data
android:name="com.webengage.sdk.android.project_number" android:value="$12345678910" />
<meta-data
android:name="com.webengage.sdk.android.auto_gcm_registration"
android:value="true" />
<receiver
android:name="com.webengage.sdk.android.WebEngagePushReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
-->
</config-file>
<config-file parent="/manifest" target="AndroidManifest.xml">
...
<!-- Remove these permissions -->
<!--
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
-->
</config-file>
</platform>
...
</widget>
And you're good to go!
iOS
Step 1: Enable Push Notifications under capabilities tab in your Xcode.
Step 2: Add WEGApnsAutoRegister
to info.plist
with value true
in config.xml
file as shown below.
<widget ...>
...
<platform name="ios">
...
<config-file parent="WEGApnsAutoRegister" target="*-Info.plist">
<true />
</config-file>
</platform>
</widget>
And you're good to go!
Please feel free to drop in a few lines at [email protected] in case you have any further queries. We're always just an email away.
Updated about a year ago