ios - React Native 推送通知 iOS - 待处理通知的数量
问题描述
我将 React Push Notifications ( https://github.com/zo0r/react-native-push-notification ) 与 localNotificationSchedule 一起用于启动通知,但在 iOS 中,推送通知的数量永远不会被破坏。
即使我选择通知,数字也不会下降......
此号码:(在桌面图标中)
我的代码:
import PushNotificationIOS from "@react-native-community/push-notification-ios";
var PushNotification = require("react-native-push-notification");
PushNotification.configure({
onRegister: function(token) {
console.log("TOKEN:", token);
},
onNotification: function(notification) {
console.log("NOTIFICATION:", notification);
let num = 0;
if (Platform.OS === 'ios') {
num = notification.data.num;
} else {
num = notification.userInfo.num;
}
switch(num) {
case 1:
NavigationService.navigate('OnePage');
break;
case 2:
NavigationService.navigate('TwoPage');
break;
default:
NavigationService.navigate('Home');
}
if (Platform.OS === 'ios') {
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
},
senderID: "YOUR GCM (OR FCM) SENDER ID",
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true
});
class IndexNavigator extends React.Component {
...
显然,根据文档,这段代码应该是正确的,但即使我按下通知并将我重定向到我想要的页面。图标中的数字永远不会减少,它总是会增加。
有谁知道为什么会发生这种情况?
解决方案
推荐阅读
- reactjs - 在 React 组件中通过 onMouseEnter 设置延迟状态
- javascript - 使用 find() 得到的对象进行三元运算
- c - 如果 fclose() 失败,文件描述符是否仍然打开?
- r - Knitr 上的自定义语言引擎
- c++ - 如何在 C++ 中打印动态数组我需要解释这个问题
- docker - 文件存在于 Singularity 容器中,但在执行时不会产生此类文件错误
- javascript - 合约部署后 Ganache 不更新账户余额
- c# - 侧边菜单的图像存储在哪里?
- php - 如何按日期顺序确定记录的编号
- uipath - 阻止用户与 UiPath 机器人交互