我的應用程序有:爲什麼「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 –