删除点击操作通知

时间:2019-05-29 07:50:13

标签: reactjs react-native react-native-android react-native-push-notification

我在点击操作时删除通知有一个小问题。

我阅读了文档和示例代码,但单击后未删除通知。

  

呼叫新通知:

PushNotification.localNotification({
    title: "Test",
    message: message,
    playSound: true,
    actions: '["Accept"]',
    tag: `${id}`,
});
  

配置并完成通知:

PushNotification.configure({
            onNotification: function (notification: any) {
                if (notification.action === 'Accept') {
                    if (orderConnection) {
                        PushNotification.cancelLocalNotifications({ id: notification.id});
                    }
                }
                notification.finish(PushNotificationIOS.FetchResult.NoData);
            },
            senderID: "YOUR GCM (OR FCM) SENDER ID",
            permissions: {
                alert: true,
                badge: true,
                sound: true
            },
            popInitialNotification: true,
            requestPermissions: true,
        });

我尝试了很多次取消通知,但是根本没有用。 也许有人遇到过同样的问题?

我使用以下版本的软件包:

"react": "16.8.2",
"react-native": "0.57.8",
"react-native-push-notification": "^3.1.3",

0 个答案:

没有答案