gpt4 book ai didi

ios - 收到远程通知时是否会回调应用程序委托(delegate)?

转载 作者:行者123 更新时间:2023-12-01 16:24:32 25 4
gpt4 key购买 nike

在收到远程通知并且用户采取行动(关闭/关闭除外)后,应用程序委托(delegate)会收到回调:

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



或者如果应用程序已注册通知操作:

-(void) application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler



我的问题是收到远程通知时应用程序是否会收到回调?那是在用户采取任何行动之前。感谢您的输入。

最佳答案

extension AppDelegate: UNUserNotificationCenterDelegate {

public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert,.sound,.badge])
print("NOtification received")
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

print("original body was : \(response.notification.request.content.title)")
print("Tapped in notification")

}
}

关于ios - 收到远程通知时是否会回调应用程序委托(delegate)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37014057/

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