On this page
FCM Notification
Set up Custom a Firebase Cloud Messaging client app on Android.
If you are creating a class that handles notify FCM, then in this new SDK version you need to change the way to handle notify FCM through the SDK system. You need to do the following steps.
- Add library in your module (app-level) Gradle
dependencies {
//...
implementation("com.google.firebase:firebase-messaging-ktx:24.0.3")
}
- Create an extend class from the base of the SDK
BaseIkFirebaseMessagingService
Please use override fun handleIntentSdk(intent: Intent)
class CustomFCMHandler: BaseIkFirebaseMessagingService() {
override fun splashActivityClass(): Class<*>? {
// return your splash activity screen
return ActSplash::class.java
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
//do something
}
override fun handleIntentSdk(intent: Intent) {
super.handleIntentSdk(intent)
// handle intent
}
}
- Add CustomFCMHandler into AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application>
...
<service
android:name=".CustomFCMHandler"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>