2014-09-27 165 views
3

我在我的应用中使用了easyapns进行推送服务。 Push在iOS 8上工作正常,但我的客户说推送不能在iPhone 6上运行。我没有iPhone 6进行检查。其他人会遇到同样的问题吗?什么可能会出错?Push无法在iPhone 6上工作

+0

是否有可能在系统设置中禁用了您的应用的通知? – Greg 2014-10-06 13:01:12

+0

不,通知仍然是他仍然没有收到push.FYI它在iPhone 5s ios8设备工作正常 – va05 2014-10-06 13:04:51

+0

这听起来像一个软件问题,而不是硬件问题。也许应用程序没有正确注册通知,或者用户不小心拒绝启用它们,并且您的应用程序未对设置中随后启用的通知作出适当的响应。 – Greg 2014-10-06 13:28:16

回答

2

以下是我在iOS 8和iPHONE 6/6 +上工作的内容。 iOS 8改变了推送通知注册的方式。以下代码将允许设备注册iOS 8和iOS 8前设备上的推送通知。

将此代码放在您的appDelegate.m在didFinishLaunchingWithOptions:

#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 

让我知道如何工作的。

+0

我已经alreday做到了这一点。推杆正在研究除iPhone 6设备以外的ios 8。 – va05 2014-10-11 06:47:50

+0

我正在升级为ios 5构建的应用程序,该应用程序是使用ios 9构建的。此代码正是我所需要的! – UberJames 2016-08-03 18:35:20

相关问题