首页 > 解决方案 > 覆盖推送消息Android的onclick行为

问题描述

我正在开发一个聊天消息应用程序。

单击推送消息时,我希望能够根据应用程序的状态影响行为。因为:

代码:

class PushMessageService : FirebaseMessagingService() {

    override fun onMessageReceived(message: RemoteMessage?) {
        // override some method that gets triggered as soon as user clicks on the push message.
    }
}

现在它启动在 Androidmanifest 中定义为 MAIN 的活动:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

我可以在那个 Activity 中添加代码,但我更喜欢 PushMessageService 来处理这个。这可能吗?

标签: androidkotlinpush-notification

解决方案


推荐阅读