1

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

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

来电新通知:

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",
4

0 回答 0