React native 角标消失方法

2019-02-26  本文已影响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)

上一篇下一篇

猜你喜欢

热点阅读