Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(firebase): add example for custom messaging service usage
Browse files Browse the repository at this point in the history
SUITEDEV-16072

Co-authored-by: pjozsef <9980358+pjozsef@users.noreply.github.com>
  • Loading branch information
megamegax and pjozsef committed Jan 22, 2019
1 parent 0d47dcd commit cef2ae2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
</intent-filter>
</service>

<service
android:name="com.emarsys.mobileengage.service.MobileEngageInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<!--If you have non-Emarsys related Push use cases,-->
<!--register your own service instead of EmarsysMessagingService.-->
<!--For a reference implementation, please take a look at com.emarsys.sample.CustomMessagingService-->
<!--<service android:name=".CustomMessagingService">-->
<!--<intent-filter>-->
<!--<action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!--</intent-filter>-->
<!--</service>-->

<meta-data
android:name="com.emarsys.mobileengage.small_notification_icon"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.emarsys.mobileengage.sample;

import com.emarsys.mobileengage.MobileEngage;
import com.emarsys.mobileengage.service.MessagingServiceUtils;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class CustomMessagingService extends FirebaseMessagingService {

@Override
public void onNewToken(String token) {
super.onNewToken(token);

MobileEngage.setPushToken(token);
}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);

boolean handledByEmarsysSDK = MessagingServiceUtils.handleMessage(
this,
remoteMessage,
MobileEngage.getConfig().getOreoConfig());

if (!handledByEmarsysSDK) {
//handle your custom push message here
}
}
}

0 comments on commit cef2ae2

Please sign in to comment.