gpt4 book ai didi

ios - Apple 的静默推送通知能否在后台启动我的应用程序?

转载 作者:可可西里 更新时间:2023-11-01 04:20:30 54 4
gpt4 key购买 nike

根据 Apple 的文档,我可以通过在 aps 有效负载字典中添加 "content-available"= 1 键值来注册静默通知。我希望我的应用程序在静默通知到达时在后台唤醒。我在我的 info.plist 中将 App downloads content in response to push notifications 值设置为 Required background modes

这是我的有效负载字典

{"aps":
{
"alert":"Notification alert","badge":1,"sound":"default","content-available":1
}
}

我在 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 中收到回调
当我的应用程序处于后台时。但我的问题是,当我们的应用程序处于终止状态时,我们能否获得对此方法或任何其他方法的回调?

我不希望我的应用用户看到通知,但我希望我的应用通过静默通知在后台唤醒它来执行某些任务。

如有任何建议,我们将不胜感激。

最佳答案

当设备收到设置了 content-available 的推送消息时,Apple 会在后台启动您的应用。用户不会意识到这一点。 From the docs :

content-available: Provide this key with a value of 1 to indicate that new content is available. Including this key and value means that when your app is launched in the background or resumed, -application:didReceiveRemoteNotification:fetchCompletionHandler: is called.

同样来自 docs

didReceiveRemoteNotification: However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

关于ios - Apple 的静默推送通知能否在后台启动我的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34291002/

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