Android with Existing Native Push
Add small ownership-checking AlgorithmX helpers to your existing FirebaseMessagingService.
Use this path if your app already owns a native FirebaseMessagingService. Complete installation and startup first. Keep your existing service and manifest entry; add these calls to it.
Your messaging service is already the entry point for Android push. Give AlgorithmX a chance to handle its messages there, then let your existing code process the rest. The helper's return value is what decides which path runs.
Forward owned messages
import algorithmx.engage.rn.AlgorithmXReactNative
import com.google.firebase.messaging.RemoteMessage
override fun onMessageReceived(message: RemoteMessage) {
if (AlgorithmXReactNative.handleFcmMessage(
this, message.data, message.notification?.title, message.notification?.body
)) return
// Your existing handling of other providers' messages.
}
The helper checks ownership and handles AlgorithmX messages. false leaves the message for your existing code. Do not also forward owned messages through the JavaScript Firebase adapter.
Next, register the phone's push address below. Once both messages and tokens are connected, you can test delivery.
Forward tokens
Add the token helper to the existing refresh callback:
override fun onNewToken(token: String) {
AlgorithmXReactNative.registerDeviceToken(token)
// Keep the token registration your app already performs.
}
A token is the address Firebase uses to reach this installation of your app. It can change, so the refresh callback above keeps AlgorithmX up to date.
Also send the current token at app startup, after native initialization in MainApplication.onCreate:
import com.google.firebase.messaging.FirebaseMessaging
FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
AlgorithmXReactNative.registerDeviceToken(token)
}
Send the current token too because a customer updating an existing app may keep the same token. AlgorithmX still needs to learn it even if Firebase does not issue a new one during the update.
Keep your permission prompt and existing notification channels. The SDK does not request permission.
Check: launch the Android app and confirm its token reaches AlgorithmX. Send an AlgorithmX message and a message from your existing provider. Each should follow its own handling once.
Next: iOS push, then shared JavaScript. Use the release checklist to verify that existing notifications remain working.
