本地消息推送

2016-08-06  本文已影响0人  我是菜鸟66666

注册本地通知

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

application.applicationIconBadgeNumber = 0;

[[UIApplication sharedApplication] cancelAllLocalNotifications];

if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

}

else {

[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge];

}

NSLog(@"%@",CURR_LANG);

return YES;

}

//触发本地通知

-(void)nonotificati{

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

if (notification!=nil)

{

notification.soundName= UILocalNotificationDefaultSoundName;

notification.applicationIconBadgeNumber = [[[UIApplication sharedApplication] scheduledLocalNotifications] count]+1;

notification.alertBody=@"寻找手机";

[[UIApplication sharedApplication]   scheduleLocalNotification:notification];

}

}

上一篇 下一篇

猜你喜欢

热点阅读