gpt4 book ai didi

iOS:推送以运行方法而不显示通知

转载 作者:行者123 更新时间:2023-11-29 01:50:10 26 4
gpt4 key购买 nike

在 iOS 中是否可以从服务器获取推送,然后运行一个方法而不显示通知?例如,检查现在是否是配置的时间,是否显示通知,如果不是则向服务器发送不可用消息。

最佳答案

是的,您正在寻找的是无声推送通知,它得到了 introduced in iOS 7 。看看 docs regarding push notifications哪个州:

The aps dictionary can also contain the content-available property. The content-available property with a value of 1 lets the remote notification act as a “silent” notification. When a silent notification arrives, iOS wakes up your app in the background so that you can get new data from your server or do background information processing. Users aren’t told about the new or changed information that results from a silent notification, but they can find out about it the next time they open your app.

content-available - number - 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. (Newsstand apps are guaranteed to be able to receive at least one push with this key per 24-hour window.)

然后,如果您觉得用户需要了解某事(虽然不是 100% 确定),您可以做出相应的 react 并最终触发另一个通知。

可以找到更深入的信息和代码 in this objc.io post .

关于iOS:推送以运行方法而不显示通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31500208/

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