项目要添加推送通知,,测试完本地通知后,发现测不了远程通知。于是想重置授权请求。
以下是重置授权请求的方法:
方法一:
通用->还原->抹掉所有内容和设置
但是第一种方法很费时,抹掉内容估计得几十分钟。于是有了第二种方法。
方法二:
将App从设备上删除
将设备完全关机再重新启动
打开 设置->通用->日期与时间里 将设备时间拔快一天以上将设备再次完全关机再重新启动
此时再安装你的App可以像纯新的流程一样进行测试所有授权,
在设置中查看你的App授权选项也是全部重置。
附上注册通知的代码:
在AppDelegate的 didFinishLaunchingWithOptions方法中,添加代码:UIApplication *app = [UIApplication sharedApplication];UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {NSLog(@"8.0注册通知");[app registerUserNotificationSettings:settings];} else {NSLog(@"7.0及以下 注册通知");[app registerForRemoteNotificationTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];}
对于IOS8 ,新增了didRegisterUserNotificationSettings方法。如果要注册RemoteNotification,需要在此方法里添加注册代码:
if (IS_IOS8) {[[UIApplication sharedApplication] registerForRemoteNotifications];}否则,如果注册通知没完成,就添加
[[UIApplication sharedApplication] registerForRemoteNotifications]会引起以下warning:
Attempting to schedule a local notification ….. with an alert but haven't received permission from the user to display alerts
版权声明:本文为博主原创文章,未经博主允许不得转载。
发光并非太阳的专利,你也可以发光