gpt4 book ai didi

ios - iOS 中 didReceiveRemoteNotification 的两个委托(delegate)方法有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:12 27 4
gpt4 key购买 nike

我在我的 iOS 应用程序中实现了 Push Notification。我可以看到 didReceiveRemoteNotification 的两个 delegate 方法,如下面的方法:这两种方法有什么区别?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { }

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  completionHandler(UIBackgroundFetchResultNewData);
}

最佳答案

第一个在 iOS 10.0 中已弃用,使用第二个。第二个信息

This method will be invoked even if the application was launched or resumed because of the remote notification. The respective delegate methods will be invoked first. Note that this behavior is in contrast to application:didReceiveRemoteNotification:, which is not called in those cases, and which will not be invoked if this method is implemented.

第一个

Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:] for user visible notifications and -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] for silent remote notifications

关于ios - iOS 中 didReceiveRemoteNotification 的两个委托(delegate)方法有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42717833/

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