gpt4 book ai didi

android - React Native PushNotification onNotification 方法

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:32:53 25 4
gpt4 key购买 nike

我正在从服务器收到通知。收到通知后,当我点击它时,同样的通知又来了。更多我点击它更多的通知来了。

我的问题是我在上面的代码中是否遵循了正确的方法?如果没有,请建议我正确的。如何处理通知的点击?因此,我可以在其点击时显示特定 View 。

我正在使用以下链接 https://github.com/zo0r/react-native-push-notification

提前致谢:)

PushNotification.configure({

onNotification: function (notification) {
console.log('NOTIFICATION:', notification)
PushNotification.localNotification({
largeIcon: "ic_launcher",
title: notification.title,
message: notification.message,
});

},
senderID: "my sender ID",
popInitialNotification: true,
requestPermissions: true,
});

最佳答案

我尝试了以下方法来解决这个问题

PushNotification.configure({

onNotification: function (notification) {
console.log('NOTIFICATION:', notification)
const clicked = notification.userInteraction;
if (clicked) {
ToastAndroid.show(notification.message,ToastAndroid.CENTER);
} else {
PushNotification.localNotification({
largeIcon: "ic_launcher",
title: "Test",
//message: JSON.stringify(xyz.notificationResponse.bookingId),
});
}
ToastAndroid.show(notification.message,ToastAndroid.CENTER);
},


senderID: "your sender id",
popInitialNotification: true,
requestPermissions: true,
});

关于android - React Native PushNotification onNotification 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44327125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com