因业务需求,使用RN开发的APP须要支持本地通知,因而研究了一下;自己想找个造好的轮子(react-native-push-notification),可是她对IOS不处理,让IOS使用PushNotificationIOS。javascript
//取消指定的本地通知 static noti_cancelLocalNotifications(userInfo){ if(YrcnApp.Platform.isIOS){ PushNotificationIOS.cancelLocalNotifications(userInfo); }else{ } } //取消全部本地通知 static noti_cancelAllLocalNotifications(){ if(YrcnApp.Platform.isIOS){ PushNotificationIOS.cancelAllLocalNotifications(); }else{ } } //检查本地通知的权限并请求受权 static noti_checkPermissions(succCallback){ if(YrcnApp.Platform.isIOS){ PushNotificationIOS.checkPermissions(function(checkPermissionsObj){ if(checkPermissionsObj.alert == "0"){ PushNotificationIOS.requestPermissions({alert:"1",badge:"1",sound:"1"}); } succCallback(); }); }else{ } } //设置本地通知 static noti_scheduleLocalNotification(obj){ if(YrcnApp.Platform.isIOS){ PushNotificationIOS.scheduleLocalNotification(obj); }else{ } } //获取本地全部通知数组 static noti_getScheduledLocalNotifications(succCallback){ if(YrcnApp.Platform.isIOS){ PushNotificationIOS.getScheduledLocalNotifications(function(getScheduledLocalNotificationsObj){ succCallback(getScheduledLocalNotificationsObj); }); }else{ } }
使用PushNotificationIOS.cancelLocalNotifications(userInfo);方法,可是须要本地通知对象的userInfo属性。java
感兴趣的朋友能够扫码下载看看。react