我正在尝试检测对通知的点击。
我使用 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
我会得到这些事件。
我已经为此苦苦挣扎了好几天,我必须intents
在我的AndroidManifest
? 有这个工作的示例项目吗?