gpt4 book ai didi

ios - 什么时候调用 didRegisterForRemoteNotificationsWithDeviceToken?

转载 作者:IT王子 更新时间:2023-10-29 07:50:02 49 4
gpt4 key购买 nike

有很多关于 didRegisterForRemoteNotificationsWithDeviceToken 的问题,但他们都回避了一个非常直接的问题,我似乎找不到确切的答案。

对于以所有其他方式正确设置通知并具有适当网络连接的应用程序:何时调用 didRegisterForRemoteNotificationsWithDeviceToken?一些可能的选择可能是:

  1. 每次应用启动时
  2. 仅在初始提示用户接受推送通知后
  3. 还有别的吗?

最佳答案

在您的 UIApplication 中调用此方法后,应用程序委托(delegate)将在成功注册远程通知后调用该方法:

(void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types

根据:http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html

When you send this message, the device initiates the registration process with Apple Push Service. If it succeeds, the application delegate receives a device token in the application:didRegisterForRemoteNotificationsWithDeviceToken: method; if registration doesn’t succeed, the delegate is informed via the application:didFailToRegisterForRemoteNotificationsWithError: method. If the application delegate receives a device token, it should connect with its provider and pass it the token.

现在,进一步详细说明,通常情况下,应用程序会在应用程序委托(delegate)的 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中调用 registerForRemoteNotificationTypes。因此,application:didRegisterForRemoteNotificationsWithDeviceToken 通常在应用程序启动后立即调用。

编辑: application:didRegisterForRemoteNotificationsWithDeviceToken 仍然会在第一次注册后被调用以进行后续注册。

关于ios - 什么时候调用 didRegisterForRemoteNotificationsWithDeviceToken?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10983536/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com