Reputation: 2811
I want to launch a specific activity when tapping a notification. I used click_action
to try to accomplish that just like below, setting it to FollowActivity
:
{
"notification": {
"title": "New follower!",
"body": "{name} is following you",
"sound": "default",
"click_action": "FollowActivity"
}
}
I also set the intent-filter
of the activity to be launched with the same action name FollowActivity
, just like what you can see below:
<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>
But when notification comes in and I tap on it, NotificationActivity
is NOT being launched. But it launch my default/activity.
What am I missing?
Upvotes: 2
Views: 246
Reputation: 10155
Is your JSON formatted correctly? Looking at the docs, looks like your click_action
should be within an android.notification
block?
{
"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"
}
}
}
}
Upvotes: 1