简体   繁体   English

IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken 未调用

[英]IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken not called

  1. In capabilities, both Push Notification and Background Mode (Remote notification) is opened.在功能中,推送通知和后台模式(远程通知)均已打开。

  2. I check the value of UIApplication.shared.isRegisteredForRemoteNotifications in my homepage.我在我的主页中检查了UIApplication.shared.isRegisteredForRemoteNotifications的值。 The value is true值为真

  3. I use 4G/3G not wifi (will it influence the APNS call back?)我使用 4G/3G 而不是 wifi(会影响 APNS 回调吗?)

  4. I use Xcode 11.1 (11A1027) and the device is Iphone 11我使用 Xcode 11.1 (11A1027) 并且设备是 Iphone 11

  5. Both didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError not called都没有调用didRegisterForRemoteNotificationsWithDeviceTokendidFailToRegisterForRemoteNotificationsWithError

  6. my code:我的代码:

     fileprivate func registerPushService() { let center = UNUserNotificationCenter.current() center.delegate = self center.requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in if (granted) { DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() } } }

registerPushService() is called on didFinishLaunchingWithOptions .didFinishLaunchingWithOptions上调用registerPushService()

============= ==============

Looks like if allowed wifi environment only...看起来如果只允许wifi环境......

Do you perhaps the .provisional option set?您是否设置了.provisional选项?

requestAuthorization(options: [.provisional, .badge, .sound, .alert])

I had the behaviour you describe with this option.我有你用这个选项描述的行为。 When I removed it, the registration went ahead and I got the token.当我删除它时,注册继续进行,我得到了令牌。 I still haven't figured out how to force it to get a token with this option short of sending local notification first to prompt the user for acceptance of notifications.我还没有弄清楚如何强制它使用此选项获取令牌,而不是首先发送本地通知以提示用户接受通知。

I would actually move UIApplication.shared.registerForRemoteNotifications() outside of the requestAuthorization block.我实际上会将UIApplication.shared.registerForRemoteNotifications()移到requestAuthorization块之外。 The confusing thing about this API is that calling registerForRemoteNotifications() and receiving a device token does not require user permission - requesting the different notification types (badge, sound, alert) is what actually triggers it.这个 API 令人困惑的是调用registerForRemoteNotifications()并接收设备令牌不需要用户许可 - 请求不同的通知类型(徽章、声音、警报)是实际触发它的原因。 Also be sure to try this on a real device - not simulator.还请务必在真实设备上尝试此操作 - 而不是模拟器。 If I recall correctly, remote notifications do not work in simulator and the delegate callbacks will not be called.如果我没记错的话,远程通知在模拟器中不起作用,并且不会调用委托回调。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS 13.x didRegisterForRemoteNotificationsWithDeviceToken 从未被调用 - iOS 13.x didRegisterForRemoteNotificationsWithDeviceToken is never called 没有为 iOS 13 调用 didRegisterForRemoteNotificationsWithDeviceToken(目标 C) - didRegisterForRemoteNotificationsWithDeviceToken not called for iOS 13 (Objective C) 在ios 9中没有调用didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios 9 iOS 11 didRegisterForRemoteNotificationsWithDeviceToken未调用 - IOS 11 didRegisterForRemoteNotificationsWithDeviceToken not called 在iOS7上没有调用didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken not called on iOS7 didRegisterForRemoteNotificationsWithDeviceToken 未在 ios 10 上调用 - didRegisterForRemoteNotificationsWithDeviceToken not getting called on ios 10 应用程序:didRegisterForRemoteNotificationsWithDeviceToken:未称为ios 10.3.2 - application:didRegisterForRemoteNotificationsWithDeviceToken: not called ios 10.3.2 在iOS 8中未调出didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios8 没有使用简单的 iOS 应用程序调用 didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken not called with simple iOS app didRegisterForRemoteNotificationsWithDeviceToken 未在 ios8 中调用,但 didRegister...Settings 是 - didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister…Settings is
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM