Firebase Integration
Information about Firebase Messaging Integration
Firebase Implementation
Step 1: Steps for Host Apps with Existing FCM Implementation
Handling Push Message
Use the following code in your FirebaseMessagingService class in method onMessageReceived
Note: Follow these steps if your application has Firebase Cloud Messaging (FCM). If not, you can skip this section.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getFrom().equals(SiprocalSDK.getFCMSenderId())) {
SiprocalSDK.handleFCMMessage(remoteMessage.getData().toString()); //can use getApplicationContext()
return;
}else{
//your implementation
}
}
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
if(message.from.equals(SiprocalSDK.getFCMSenderId(applicationContext))){
SiprocalSDK.handleFCMMessage(message.data.toString())
return
}else{
//your implementation
}
}
Handling Token Firebase
Use the following code in your FirebaseMessagingService class in onNewToken:
@Override
public void onNewToken(String s){
super.onNewToken(s);
// your code
SiprocalSDK.refreshFCMToken(applicationContext); //can use getApplicationContext()
}
override fun onNewToken(token: String) {
// your code
SiprocalSDK.refreshFCMToken(applicationContext)
}
Step 2: Configure Siprocal Server for the Host App
Minimal configuration needs to be done on the Siprocal Server to connect to the host app via FCM. Provide the package name of the host app to SDK provider.
Updated 7 months ago