[英]How to send Push Notification With Custom Click Action From Firebase Console
I'm going to send push notification with custom click action to set onClick
of notification to open an exact Activity
in my project when the app is in foreground or background. 我将发送带有自定义点击操作的推送通知,以设置
onClick
通知,以便在应用处于前台或后台时在我的项目中打开确切的Activity
。 In all posts and comments it is written that it is impossible to send notification with custom click action from console, but in "Advanced options" in console, it is possible to set custom data keys and values. 在所有帖子和评论中写道,无法从控制台发送带有自定义点击操作的通知,但在控制台的“高级选项”中,可以设置自定义数据键和值。
Why it should be impossible to set click_action
key and its value? 为什么不可能设置
click_action
键及其值?
If it is possible so tell me what should I do. 如果可能的话告诉我该怎么做。 I mean what is the exact intent-filter code?
我的意思是什么是精确的intent-filter代码? and what should I set as
click_action
value? 我应该将
click_action
值设置click_action
?
Assume that I want to open SecondActivity
by clicking on notification. 假设我想通过单击通知来打开
SecondActivity
。
yes you can't send notification like this from the firebase console but this is how it works you need to add intent_filter
to the activity at the manifest.xml
是的,你不能从firebase控制台发送这样的通知,但这就是它的工作原理你需要在
manifest.xml
的活动中添加intent_filter
<activity android:name=".MyActivity">
<intent-filter>
<action android:name="com.mypackage.MyActivty_TARGET" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
and put your click_action
value as the activity action : com.mypackage.MyActivty_TARGET"
并将您的
click_action
值作为活动操作: com.mypackage.MyActivty_TARGET"
and you read the data from the android like this : 你从这里读取android的数据:
String click_action = remoteMessage.getNotification().getClickAction();
Intent in = new Intent(click_action);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.