zoukankan      html  css  js  c++  java
  • React Native 插件系列之PushNotificationIOS

    1、背景

      因业务需求,使用RN开发的APP需要支持本地通知,于是研究了一下;本身想找个造好的轮子(react-native-push-notification),但是她对IOS不处理,让IOS使用PushNotificationIOS。

    2、主要代码

      //取消指定的本地通知
        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{
    
            }
        }
    

    3、遇到的问题

      如何取消指定的通知?

      使用PushNotificationIOS.cancelLocalNotifications(userInfo);方法,但是需要本地通知对象的userInfo属性。

    4、生产上的使用

      感兴趣的朋友可以扫码下载看看。

      还款记录仪

      

  • 相关阅读:
    easyui学习笔记1—增删改操作
    sql点滴37—mysql中的错误Data too long for column '' at row 1
    javascript获取当前url
    escape()、encodeURI()、encodeURIComponent()区别详解
    js文本框提示和自动完成
    javascript js string.Format()收集
    超链接标签为什么会造成页面颤抖
    asp.net mvc 4.0常见的几个问题
    如何使用Flashfxp上传下载文件
    点击按钮显示谷歌地图
  • 原文地址:https://www.cnblogs.com/yrcn/p/7412191.html
Copyright © 2011-2022 走看看