如何知道是否从android通知托盘中打开了该应用程序?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何知道是否从android通知托盘中打开了该应用程序?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1454字,纯文字阅读大概需要3分钟。
内容图文
如何知道是否从android通知托盘中打开了该应用程序?例如,我已经关闭了该应用程序(已从最近的应用程序列表中清除).但是我从后端Websocket收到通知,我按了它,它打开了应用程序.所以我的问题是,有没有办法检查通知是否打开?
解决方法:
很简单,您可以在推送通知侦听器中接收通知负载
import PushNotification from 'react-native-push-notification'
configurePushNotifications = () => {
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log('PushNotification token', token)
},
onNotification是您将收到本地或远程通知的位置,当用户单击通知托盘时将调用该通知
onNotification: function(notification) {
console.log('notification received', notification)
},
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true,
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
})
}
这就是通知对象的外观
{
foreground: false, // BOOLEAN: If the notification was received in foreground or not
userInteraction: false, // BOOLEAN: If the notification was opened by the user from the notification area or not
message: 'My Notification Message', // STRING: The notification message
data: {}, // OBJECT: The push data
}
内容总结
以上是互联网集市为您收集整理的如何知道是否从android通知托盘中打开了该应用程序?全部内容,希望文章能够帮你解决如何知道是否从android通知托盘中打开了该应用程序?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。