0
我有我的應用程序使用支持推送通知功能的企業證書籤名。它工作正常,當我更新iPhone到iOS 8推送通知停止工作。經過調試和研究之後,我開始知道下面的代碼需要添加以從iOS 8開始檢索推送令牌。推送通知停止工作IOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) //>iOS8
{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}else {// <iOS8
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
Add following callback methods,
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
//handle the actions
}
但是,我們不會遇到與我們的應用程序的應用程序版本和所有工作良好的這個問題。它僅僅是在企業認證方面打破了什麼?
有你在你的info.plist文件中添加 「NSLocationWhenInUseUsageDescription」? – Urmi 2014-09-26 10:10:31
是否真的需要推送通知? – Pankaj 2014-09-26 10:37:06
是的。是嗎。否則應用程序將無法接收推送通知。 [鏈接](https://developer.apple.com/library/prerelease/iOS/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html)在討論部分中檢查以下行:「用戶提示包含NSLocationWhenInUseUsageDescription鍵中的文本在您應用程序的Info.plist文件中,調用此方法時需要該鍵的存在。「 – Urmi 2014-09-26 10:47:43