简体   繁体   English

知道何时单击FireBase通知

[英]Know when a FireBase Notification has been clicked

Is there a way to know that a user has clicked on a notification when the application is in the foreground? 当应用程序位于前台时,是否有办法知道用户单击了通知?

I need to send analytics for when users click on the notification and I need to know when they have clicked it. 我需要发送有关用户何时单击通知以及何时单击通知的分析。

I can't put the analytics in the destination activity as I have other analytics that are sent when the user gets to that screen. 我无法将分析放在目标活动中,因为当用户进入该屏幕时,我还会发送其他分析。 I need to know that a user has specifically clicked on the notification to open the destination activity. 我需要知道用户已专门单击通知以打开目标活动。

For example is there a callback for when a user clicks on the notification? 例如,当用户单击通知时是否存在回调?

Thank you 谢谢

您应该在NotificationCompat.Builder中使用.setContentIntent(pendingIntent)并将其放入该intent变量中,然后在应用启动时,应检查此变量是否存在于目标活动的意图中,如果为true,则发送分析数据(如果需要) ,我可以给代码示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM