gpt4 book ai didi

ios - 为什么 didReceiveRemoteNotification :fetchCompletionHandler is called but usual didReceiveRemoteNotification isn't?

转载 作者:可可西里 更新时间:2023-11-01 04:23:31 25 4
gpt4 key购买 nike

在我的应用程序中,我有两种类型的推送通知:带有 content-available = 1 标志的远程静默通知和带有 bodybadge< 的普通推送通知 和其他东西。

我还定义了两个委托(delegate)方法 didReceiveRemoteNotification:fetchCompletionHandler 和常用的 didReceiveRemoteNotification

但是当没有content-available 标志的推送通知到达时,调用didReceiveRemoteNotification:fetchCompletionHandler,而不是didReceiveRemoteNotification

如何解决这个问题?
为什么我不能为后台推送和常规推送设置两个委托(delegate)方法?

最佳答案

iOS 7 只调用新的,这是我在我的应用程序中处理它的方式:

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

// Pass on
[self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:nil];

}

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

// Check if in background
if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) {

// User opened the push notification

} else {

// User hasn't opened it, this was a silent update

}

}

关于ios - 为什么 didReceiveRemoteNotification :fetchCompletionHandler is called but usual didReceiveRemoteNotification isn't?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21854350/

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