gpt4 book ai didi

ios - iOS 有类似 Android 的 AlarmManager 的东西吗?

转载 作者:IT王子 更新时间:2023-10-29 05:51:02 24 4
gpt4 key购买 nike

iOS 的 Android AlarmManager 类替代品是什么?

到目前为止,我发现的最接近的东西是 NSTimer。但这只有在你的应用程序启动时才有效,一旦它进入后台就无法工作,我需要在后台运行一些功能并根据我的业务逻辑来决定我是否想做某事。例如,如果满足某些条件,则显示本地通知。

我发现的唯一解决方法是使用远程推送通知(静默通知)来唤醒应用,然后您可以从那里实现您的业务逻辑。

重要提示

根据我在几个地方发现的情况,人们提示使用静默通知来执行此操作,因为您的应用程序可能会在应用商店中被拒绝。

最佳答案

没有

如评论中所述,the documenation对此很清楚:

Always try to avoid doing any background work unless doing so improves the overall user experience. An app might move to the background because the user launched a different app or because the user locked the device and is not using it right now. In both situations, the user is signaling that your app does not need to be doing any meaningful work right now.

有以下异常(exception)情况:

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

  • Apps that play audible content to the user while in the background, such as a music player app

  • Apps that record audio content while in the background

  • Apps that keep users informed of their location at all times, such as a navigation app

  • Apps that support Voice over Internet Protocol (VoIP)

  • Apps that need to download and process new content regularly

  • Apps that receive regular updates from external accessories

关于ios - iOS 有类似 Android 的 AlarmManager 的东西吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35943191/

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