我已经将我的设备升级到iOS 9,Xcode环境升级到7.0测试版。推送通知在iOS 9中不起作用?
这是我的代码:
float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
if(ver >= 8 && ver<9)
{
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
}else if (ver >=9){
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else{
//iOS6 and iOS7 specific code
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert];
}Push通知在用Xcode 6.4构建的iOS 8到8.3上运行良好。
发布于 2016-07-21 15:37:36
发布于 2015-10-07 03:13:21
我也遇到了同样的问题。我通过创建一个Ad配置文件来解决这个问题。我注意到当我使用开发配置文件时,没有发生推送。我注意到的另一件事是,每次新安装时,设备令牌都会被更改,这有点奇怪,因为我们必须更新每个新实例的服务器。
为了获得更好的理解,您可以阅读本文:iOS 9推送通知
发布于 2015-11-06 12:13:04
用didFinishLaunchingWithOptions编写这段代码
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];并将此方法添加到AppDelegate中,因为我已用于解析推送通知服务。
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"global" ];
[currentInstallation saveInBackground];
}https://stackoverflow.com/questions/32718273
复制相似问题