Tôi bằng cách nào đó không thể nhận được mã thông báo thiết bị khi đăng ký các thông báo từ xa. Tôi nhận được các phương thức nói "Bạn có muốn cho phép App X có thể gửi cho bạn notificaitons", nhưng khi tôi chấp nhận nó, các didRegisterForRemoteNotifications chức năng không được gọi.Mã thông báo thiết bị không nhận được khi đăng ký các thông báo từ xa trong Swift
Khi tôi đăng ký thông báo từ xa trong iOS 8/Swift sử dụng mã này:
UIApplication.sharedApplication().registerForRemoteNotifications()
let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
Các chức năng này không được kích hoạt ở tất cả:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!)
và
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError!)
tuy nhiên khi tôi đăng nhập
này 210println("current settings \(UIApplication.sharedApplication().currentUserNotificationSettings()) and \(UIApplication.sharedApplication().isRegisteredForRemoteNotifications())")
tôi nhận
"current settings <UIUserNotificationSettings: 0x170437120; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);> and true"
hồ sơ provisioning tôi và giấy chứng nhận ar tất cả theo thứ tự.
Có ai khác đã gặp sự cố này không?
Tại sao bạn gọi 'registerForRemoteNotifications()' hai lần? – ricardopereira
1) tạo thông báo đẩy và đính kèm với hồ sơ của bạn 2) về khả năng đẩy thông báo 3) Gửi mã thông báo thiết bị xem thêm câu trả lời của tôi là có –