Jas*_*ker 18 xcode apple-push-notifications ios xcode6 ios8
如果设备注册通知的方式发生了重大变化,我们无法使用registerForRemoteNotificationTypes:如果我们不能使用Xcode 6 beta,我们如何构建新版本的应用程序以支持iOS 8?我们是否必须构建并提交Xcode 6 GM版本发布的日期,以便我们的用户继续获得推送通知?
Raş*_*LAN 50
iOS 8已更改通知注册.因此,您需要检查设备版本,然后您需要注册通知设置.(请检查此链接.)我在Xcode 6上尝试此代码,它为我工作.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
ale*_*nca 17
您可能需要考虑使用respondsToSelector而不是检查系统版本:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]){
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
Run Code Online (Sandbox Code Playgroud)
Muh*_*dil 10
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
#else
[[UIApplication sharedApplication] registerForRemoteNotificationTypes(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif
Run Code Online (Sandbox Code Playgroud)
根据 Apple 文档,registerForRemoteNotificationTypes:iOS 8 中已弃用,您可以使用registerForRemoteNotifications和registerUserNotificationSettings:。
Xcode 6 beta 和 iOS 8 beta 是预发布软件。Beta 版本仅用于开发和测试。新的应用程序和应用程序更新必须使用 Xcode 和 iOS 的发行版本构建,才能提交到 App Store。
| 归档时间: |
|
| 查看次数: |
22136 次 |
| 最近记录: |