<application
//....
>
//...
<service
android:name=".messaging.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
//...
</application
- 点击通知栏后,会回调onNewIntent(),配置如下
<activity android:name=".activity.CloudMessagingActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
processIntent()
var bundles = intent.extras
if(bundles != null) {
for (key in bundles.keySet()) {
val value: Any? = bundles.get(key)
Log.d(tag, "${key} ${value.toString()}"
)
}
}
}