Overview
Skill Level: Any
Prerequisites
Not what you’re looking for? Check out all our available tutorials for mobile app messaging here.
Â
Â
Step-by-step
-
Call new token
The sdk messaging api has new interface method for customers that use their own fcm implementation:
com.ibm.mce.sdk.api.MessagingApi.reportToken(Context, token) – should be called when a new registration token is detected.
Sample of how a customer FCM implementation should look:
import androidx.annotation.NonNull; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import com.ibm.mce.sdk.api.MessagingApi; import com.ibm.mce.sdk.api.fcm.FcmApi; public class CustomFcmMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { if(FcmApi.isFcmMessage(remoteMessage)) { FcmApi.handleMceFcmMessage(getApplicationContext(), remoteMessage); } else { // this is not sdk message. Handle it here } } @Override public void onNewToken(@NonNull String token) { MessagingApi.reportToken(getApplicationContext(), token); // any other code that uses the token goes here } }
Expected outcome
Expected Outcome: Need more help? Check out all of our available tutorials for mobile app messaging here.
Â