iOS 8推送注册方式改变的问题
来源:互联网 发布:淘宝网店开店考试 编辑:程序博客网 时间:2024/06/06 04:53
iOS 8发布之后,不过有的开发者也注意到了在iOS 8上推送通知的注册方式有所变化,报错提示为:
1
registerForRemoteNotificationTypes: is not supported
in
iOS 8.0 and later.
之后国外有开发者在使用了新的解决方案注册成功后发现在iPhone 6上仍然不能运行。鉴于iPhone 6/6 Plus将在国内开售,我们大可未雨绸缪一下。
iOS 8因为改变了推送消息的注册方式,所以在有推送需求的应用开发时,需要有些与以前不同的修改。然后可以试试在appDelegate.m文件的didFinishLaunchingWithOptions方法中加入下面一段代码以避免在iPhone 6/6 Plus上出现问题:
1
2
3
4
5
6
7
8
9
10
11
12
#ifdef __IPHONE_8_0 //这里主要是针对iOS 8.0,相应的8.1,8.2等版本各程序员可自行发挥,如果苹果以后推出更高版本还不会使用这个注册方式就不得而知了……
if
([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
else
{
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
#else
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
#endif
然后在appDelegate.m中加入此方法:
1
2
3
4
5
6
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
#endif
0 0
- iOS 8推送注册方式改变的问题
- iOS 8推送注册方式改变的问题
- iOS 8推送注册方式改变的问题
- iOS 8推送注册方式改变的问题
- iOS 8推送注册方式改变的问题
- iOS推送的问题
- iOS 8.0 推送注册
- IOS delegate注册推送
- 关于ios注册推送
- IOS delegate注册推送
- iOS消息推送注册
- iOS 注册推送失败
- iOS 注册极光推送
- iOS 推送的 小问题
- iOS开发----iOS8 注册推送
- 【IOS】ios8推送消息注册
- iOS - 注册远程推送通知
- IOS开发者注册的问题
- 悬浮地板可用于室外做运动地板?
- 油滴扩展 题解
- 当ListView为空时,显示特定的View
- java中使用自己的邮箱进行多人邮件发送
- 闰年、素数
- iOS 8推送注册方式改变的问题
- 《Linux程序设计》——套接字
- 使用SQL*Loader将CSV文件数据导入ORACLE
- TLibVideoIO库分析
- 关于JSP复选框页面传值
- n factorial
- HTML的片段的替换
- 几种获取request,session方法
- 幼儿园地板装修,不用愁!