In our integration docs we show the easiest way to integrate push notifications with Swrve. This assumes that Swrve is the only push provider. This method uses the default SwrveFirebaseMessagingService to handle processing of push notifications and updating push tokens in Swrve.
If you have multiple push providers you will need create your own Messaging Service to handle push notifications. You will need to pass new tokens to Swrve and make sure Swrve is set to handle incoming notifications.
Here is an example project in github showing exactly how you should do it:
https://github.com/Swrve/swrve-android-sdk/tree/release-7_2_1/samples/MultipleFCMProviders
Instead of pointing to the default SwrveFirebaseMessagingService you point to your own Messaging Service in the AndroidManifest.
In the example project we call it "MyFirebaseMessagingService".
Here you override two methods:
onNewToken() -
This is called when a new token is generated. Here you need to pass the token to Swrve by calling:
com.swrve.sdk.SwrveSDK.setRegistrationId(token);
onMessageReceived() -
This is called when a notification is received on the device. Here you need to pass the notification to the Swrve SDK by calling:
if (!SwrvePushServiceDefault.handle(this, remoteMessage.getData())) {
// Execute code for other push provider
}
Swrve will only handle the push if it came from Swrve. If not you can execute your own code inside the if statement to handle it yourself.
Comments