我已经在我的应用程序中使用了easyapns作为推送服务。推送在iOS 8上工作正常,但我的客户说推送在iPhone 6上不工作。我没有iPhone 6可以检查。其他人还会遇到同样的问题吗?有什么可能出错?
发布于 2014-10-11 02:08:50
这是我在iOS 8和iPHONE 6/6+上的工作经验。iOS 8改变了推送通知注册的工作方式。以下代码将允许设备在iOS 8和iOS 8之前的设备上注册推送通知。
将此代码放在didFinishLaunchingWithOptions中的appDelegate.m中:
#ifdef __IPHONE_8_0
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中
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
#endif让我知道它是如何工作的。
https://stackoverflow.com/questions/26074608
复制相似问题