码迷,mamicode.com
首页 > 移动开发 > 详细

iOS8测试本地推送遇到问题

时间:2015-04-26 01:12:56      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

xcoce 老报这个错

{fire date = Friday, February 6, 2015 at 5:42:00 PM China Standard Time, time zone = (null), repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Friday, February 6, 2015 at 5:42:00 PM China Standard Time, user info = (null)} with an alert but haven’t received permission from the user to display alerts

 

分析原因:

是api有变

  

/*
报错信息可能如下:
1 Attempting to schedule a local notification
2 with an alert but haven‘t received permission from the user to display alerts
3 with a sound but haven‘t received permission from the user to play sounds
*/
//ios8中,在APP启动后增加如下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//设置window
  //ios8  注册本地通知
  if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationSettings *noteSetting =[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound
                                           categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:noteSetting];
  }
}

iOS8测试本地推送遇到问题

标签:

原文地址:http://www.cnblogs.com/BinZone/p/4457201.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!