适用于Android AlarmManager的iOS替代品 [英] iOS alternative for Android AlarmManager

查看:122
本文介绍了适用于Android AlarmManager的iOS替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是iOS Swift 2替代Android AlarmManager.

What is iOS Swift 2 alternative to Android AlarmManager.

到目前为止,我发现关闭的东西是NSTimer.但这仅在您的应用程序启动后才起作用,一旦进入后台就将无法运行,并且我需要在后台以及从业务逻辑中运行某些功能来决定是否要执行某项操作...例如,如果满足某些条件以显示本地通知.

So far the closes thing that I found is NSTimer. But that works only when your application is up, once it goes to the background it won't work, and I need to run some function in the background and from my business logic to decide if I want to do something or not...for example if some condition is satisfied to display local notification.

编辑

对于那些有相同问题的人,简单的答案就没有在iOS上那样.

For these who have the same question, simple answer there's nothing like that on iOS.

唯一的解决方法是仅使用远程推送通知(静默通知)来唤醒应用程序,然后您就可以实施业务逻辑.

*重要提示

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

From what I have found on few places is that people are complaining about using silent notifications to do this because your application might be rejected on app store.

如果在应用商店中有人在使用这种方法处理他的应用,请分享您的经验.

If there's anyone there who is using this approach for his app on app store please share your experience.

推荐答案

没有.

如评论中所述,文档化在这一点上很清楚:

As already stated in the comments, the documenation is quite clear on that:

始终尝试避免进行任何后台工作,除非这样做会改善整体用户体验.应用程序可能会移至后台,这是因为用户启动了其他应用程序,或者是因为用户锁定了该设备并且当前未使用它.在这两种情况下,用户都表示您的应用现在不需要做任何有意义的工作.

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.

,但以下情况除外:

对于需要更多执行时间才能实现的任务,您必须请求特定权限才能在后台运行它们而不暂停它们.在iOS中,只允许特定的应用类型在后台运行:

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

支持互联网协议语音(VoIP)的应用

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

这篇关于适用于Android AlarmManager的iOS替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆