【发布时间】:2020-04-20 09:40:55
【问题描述】:
我正在尝试检测对通知的点击。
我使用 react-native 0.61 和:react-native-notifications 3.1.4(但使用 react-native-push-notification 3.1.9 得到相同的结果)。
一切正常,但只有一件事:如果我点击通知,或者如果我从带有 Firebase 管理员通知的通知中打开我的应用程序(或 curl 到 FCM),我不会触发这些事件:
Notifications.events().registerNotificationOpened
和
Notifications.getInitialNotification()
但是,如果我使用 Notifications.postLocalNotification 发布一个简单的本地通知,一切正常。
这是我的标准 curl 请求:
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=mykey' \
-H 'Content-Type: application/json' \
-H 'Host: fcm.googleapis.com' \
-d '{
"to" : "cgh6P5BESPesyBJwYlaSPi:APA91bEuLwxgZq4JUlo2Su-_l1DqNVoAPzC2eHQy07IQlTuUcZNRuFiLzlbiFuCsHhU74SgYbrIkY7e2v4uQbYCspzRLlDrwrfha40Ozv613xwyYPtR3lJMaTuNcNAhGh8bdrmMY4B3N",
"payload" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"pushNotification": true,
}
再次出现通知,但如果我点击它,我不会触发任何事件。但是,如果我使用 postLocalNotification 我会收到这些事件。
我已经为此苦苦挣扎了好几天,我是否必须在我的AndroidManifest 中对intents 做点什么?有这个工作的示例项目吗?
【问题讨论】:
标签: android react-native push-notification react-native-push-notification react-native-notifications