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

解决iOS8不能正常进行本地推送问题(Attempting to schedule a local notification)

时间:2015-02-26 16:41:42      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:uilocalnotification   ios8   local notification   attempting to schedu   本地推送   

错误内容

Attempting to schedule a local notification <UIConcreteLocalNotification: 0x15686ff0>{fire date = 2015年2月26日 星期四 中国标准时间下午3:14:57, time zone = Asia/Shanghai (GMT+8) offset 28800, repeat interval = NSCalendarUnitDay, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = 2015年2月26日 星期四 中国标准时间下午3:14:57, user info = {
key = name;

}} with a badge number but haven‘t received permission from the user to badge the application

问题原因

iOS8要实现badge、alert和sound等都需要用户同意才能进行。

解决方案

先注册一下通知,弹出对话框,用户同意后,就能进行本地推送了。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //处理iOS8本地推送不能收到
    float sysVersion=[[UIDevice currentDevice]systemVersion].floatValue;
    if (sysVersion>=8.0) {
        UIUserNotificationType type=UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
        UIUserNotificationSettings *setting=[UIUserNotificationSettings settingsForTypes:type categories:nil];
        [[UIApplication sharedApplication]registerUserNotificationSettings:setting];
    }
    return YES;
}



解决iOS8不能正常进行本地推送问题(Attempting to schedule a local notification)

标签:uilocalnotification   ios8   local notification   attempting to schedu   本地推送   

原文地址:http://blog.csdn.net/u011439689/article/details/43953553

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