美文网首页
React native 角标消失方法

React native 角标消失方法

作者: 海利昂 | 来源:发表于2019-02-26 11:07 被阅读0次

    角标 消失方法

    -(void)applicationDidEnterBackground:(UIApplication *)application {

      [self resetBageNumber];

      [JPUSHService setBadge:0];

    }

    -(void)resetBageNumber{

      if(IOS11){

        /*

         iOS 11后,直接设置badgeNumber = -1就生效了

         */

        [UIApplication sharedApplication].applicationIconBadgeNumber = -1;

      }else{

        UILocalNotification *clearEpisodeNotification =[[UILocalNotification alloc]init];

        clearEpisodeNotification.fireDate =[NSDate dateWithTimeIntervalSinceNow:(0.3)];

        clearEpisodeNotification.timeZone =[NSTimeZone defaultTimeZone];

        clearEpisodeNotification.applicationIconBadgeNumber = -1;

        [[UIApplication sharedApplication]scheduleLocalNotification:clearEpisodeNotification];

      }

    }

    //宏文件判断机型

    #define IOSVersion[[[[[UIDevice currentDevice]systemVersion]componentsSeparatedByString:@"."]objectAtIndex:0]intValue]

    #define IOS8([[[[[UIDevice currentDevice]systemVersion]componentsSeparatedByString:@"."]objectAtIndex:0]intValue]>= 8?1:0)

    #define IOS9([[[[[UIDevice currentDevice]systemVersion]componentsSeparatedByString:@"."]objectAtIndex:0]intValue]>= 9?1:0)

    #define IOS11([[[[[UIDevice currentDevice]systemVersion]componentsSeparatedByString:@"."]objectAtIndex:0]intValue]>= 11?1:0)

    相关文章

      网友评论

          本文标题:React native 角标消失方法

          本文链接:https://www.haomeiwen.com/subject/wftayqtx.html