在iOS8之后,以前的本地推送写法可能会出错,接收不到推送的信息,
如果出现以下信息:
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下没有注册,所以需要额外添加对IOS8的注册方法,API中有下面这个方法:
// Registering UIUserNotificationSettings more than once results in previous settings being overwritten.
- (void)registerUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings NS_AVAILABLE_IOS(8_0);
这个方法是8.0之后才能使用的,所以需要判断一下系统的版本。
第一步:注册本地通知:
// 设置本地通知
+ (void)registerLocalNotification:(NSInteger)alertTime {
UILocalNotification *notification = [[UILocalNotification alloc] init];
// 设置触发通知的时间
NSDate

本文介绍了在iOS8及以上版本中如何正确实现本地推送。由于iOS8之后的变化,使用旧方法可能无法正常接收到本地通知。文章提供了一步步的注册本地通知的教程,并提供了示例代码的下载链接。
最低0.47元/天 解锁文章
1224

被折叠的 条评论
为什么被折叠?



