gpt4 book ai didi

ios - didReceiveRemoteNotification : is not called after notification arrives and app is in background/suspended mode

转载 作者:搜寻专家 更新时间:2023-11-01 06:26:44 24 4
gpt4 key购买 nike

AppDelegate 中,我只需更新 applicationIconBadgeNumber:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
application.applicationIconBadgeNumber += 1
}

当应用程序连接到 Xcode 并且处于调试器模式时,一切都按预期工作。但是就在我将其从 Xcode 中拔出后,通知到达但角标(Badge)未更新。应用处于后台模式

为什么?我的方法有什么问题?请给我一个建议🏆

最佳答案

推送通知由 iOS 而非您的应用程序处理,您无法在收到推送通知时更改应用程序角标(Badge)。您可以在推送通知的负载中发送角标(Badge)编号,

有效载荷可能如下所示:

{
"aps" : {
"alert" : "Notification REceived",
"badge" : 1
}
}

关于ios - didReceiveRemoteNotification : is not called after notification arrives and app is in background/suspended mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53332889/

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