无法为推送通知注册(X code 7,iOS9) [英] Unable to register for Push Notifications (Xcode 7, iOS9)
问题描述
我升级我的设备到iOS 9和我的X code环境,7.0(7A220)。通过对通知我的应用程序寄存器:
I've upgraded my devices to iOS 9 and my Xcode environment to 7.0 (7A220). My app registers for notifications via:
[[UIApplication sharedApplication] registerForRemoteNotifications];
然而,无论是didRegisterForRemoteNotificationWithDeviceToken或didFailToRegisterForRemoteNotificationsWithError被调用。此外,我的应用程序不会出现在设置 - >通知部分(这告诉我,它甚至没有试图进行远程注册/推送通知)
However, neither "didRegisterForRemoteNotificationWithDeviceToken" or "didFailToRegisterForRemoteNotificationsWithError" are called. Furthermore, my app does not appear in the Settings->Notifications section (which tells me its not even trying to register for remote/push notifications)
我的应用程序ID启用了以下应用服务:
My App ID has the following Application Services enabled:
- 游戏中心
- 在应用程序内购买
- 推送通知
在X code,启用了以下功能:
In Xcode, the following capabilities enabled:
-
推送通知
Push Notifications
背景模式(远程通知)
这与iOS 8工作得很好,具有以X code 6.还内置应用程序,它不再当X code 7建成使用iOS设备8的工作。
This worked fine with iOS 8, with app built with Xcode 6. Also, it no longer works with an iOS 8 device when built with Xcode 7.
推荐答案
你使用模拟器?
在一个模拟器,远程通知,不支持。
In a simulator, remote notifications are not supported.
样code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let pushSettings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Badge ,UIUserNotificationType.Sound ,UIUserNotificationType.Alert], categories: nil)
application.registerUserNotificationSettings(pushSettings)
return true
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
application.registerForRemoteNotifications()
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let token=deviceToken.description
print(token)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
}
X $ C $ç说:
Xcode says:
Error Domain=NSCocoaErrorDomain
Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION"
UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
这篇关于无法为推送通知注册(X code 7,iOS9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!