我的应用程序有:为什么“didRegisterForRemoteNotificationsWithDeviceToken”没有被调用n swift 3,iOS 10,XCode 8?
APP ID - 推送通知启用,
提供个人资料(开发) - 推通知启用,
目标 - 能力 - 启用推送通知,
目标 - 背景模式 - 背景取,远程通知启用
在的appDelegate 1. import UserNotifications
2. class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDelegate, UNUserNotificationCenterDelegate
3.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *)
{
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.badge, .sound, .alert], completionHandler: { (granted, error) in
if error == nil
{
//UIApplication.shared.registerForRemoteNotifications()
application.registerForRemoteNotifications()
}
else
{
print("\(error?.localizedDescription)")
}
})
}
else
{
registerForPushNotifications(application)
// Fallback on earlier versions
}
}
但didRegisterForRemoteNotificationsWithDeviceToken
是不会被调用,而不是didFailToRegisterForRemoteNotificationsWithError
越来越通话
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
继错误我得到的didFailToRegisterForRemoteNotificationsWithError
域= NSCocoaErrorDomain代码= 3000“没有有效的“aps-环境'应用程序的权利字符串“UserInfo = {NSLocalizedDescription =无效的'aps-environment'应用程序的权利字符串}
我错过了什么吗?
添加要在'didFailToRegisterForRemoteNotificationsWithError'收到错误。 –
@NiravD我已经更新了我的问题,在执行中是否有任何缺失? – sss
看看这一个http://stackoverflow.com/questions/27324020/no-valid-aps-environment-entitlement-string-found-for-application-on-app-store和这个http://stackoverflow.com/ questions/10987102/how-to-fix-no-valid-aps-environment-entitlement-string-found-for-application –