Click_Action不启动指定的活动



我想在敲击通知时启动特定活动。我使用 click_action尝试像下面一样实现这一目标,将其设置为 FollowActivity

{
  "notification": {
    "title": "New follower!",
    "body": "{name} is following you",
    "sound": "default",
    "click_action": "FollowActivity"
  }
}

我还设置了将使用相同动作名称FollowActivity启动的活动的intent-filter,就像您可以在下面看到的那样:

<activity
            android:name=".NotificationActivity"
            android:label="Notification"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="FollowActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

但是,当通知进来并且我点击它时,NotificationActivity不会启动。但是它启动了我的默认/活动。

我缺少什么?

您的JSON格式正确吗?查看文档,看起来您的click_action应该在android.notification块内?

https://firebase.google.com/docs/cloud-messaging/concept-options#example_notification_message_message_message_with_platform-specific_delivery_options

{
  "message":{
     "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
     "notification":{
       "title":"Match update",
       "body":"Arsenal goal in added time, score is now 3-0"
     },
     "android":{
       "ttl":"86400s",
       "notification"{
         "click_action":"OPEN_ACTIVITY_1"
       }
     },
     "apns": {
       "headers": {
         "apns-priority": "5",
       },
       "payload": {
         "aps": {
           "category": "NEW_MESSAGE_CATEGORY"
         }
       }
     },
     "webpush":{
       "headers":{
         "TTL":"86400"
       }
     }
   }
 }

相关内容

  • 没有找到相关文章

最新更新