使背景的iOS超过3分钟定时运行 [英] make timer run on background iOS for more than 3 minutes

查看:385
本文介绍了使背景的iOS超过3分钟定时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要这个程序为3分钟以上运行定时器和播放声音非常像45秒,这里的大部分解决方案都只是在iOS上不超过3分钟。有没有办法让它运行所有的时间,除非应用程序会停止?

经过研究,我想解决的办法是实施 beginBackgroundTaskWithExpirationHandler

和通过给处理程序,并设置位置更新的的plist 停止了吗?

至于音频,除了设置的plist,什么都需要做播放音频?

​​斯威夫特如何使用的NSTimer背景?
iphone - 在后台 NSTimers
<超过10分钟href=\"http://stackoverflow.com/questions/9738488/run-app-for-more-than-10-minutes-in-background\">​​运行的应用程序/ p>

解决方案

没有,为了拯救我们大家从杀死我们的电池应用,苹果不允许应用程序继续在后台运行多了几个分钟。只有非常特殊的限制(音乐播放应用,VOIP,导航应用等),使正在进行的操作。在细节方面,这在<一个描述href=\"https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW1\"相对=nofollow>后台执行一章的应用编程指南适用于iOS。

如果你想在未来的某个时间通知用户的东西,你可以使用本地通知。当你这样做,不过,你不用管是否你的应用程序重新启动或没有。只有当用户点击的通知(假设他们甚至授予您的应用程序的通知权限的话),将应用程序重新开放。欲了解更多信息,请参阅在<一的本地通知讨论href=\"https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html#//apple_ref/doc/uid/TP40008194\"相对=nofollow>本地和远程通知编程指南。但是注意,这并不意为每45秒的警报,而是为定于将来某个时间显著通知

有关的一个如何与计时器嫁给本地通知,请参阅 href=\"http://stackoverflow.com/questions/34496389/swift-nstimer-in-background\">​​迅速的NSTimer这跟进问题迅速计算时间,在后台运行的定时器。

So I need this app to run timer for more than 3 minutes, and play a sound like very 45 seconds, most of the solutions here are just for less than 3 minutes on iOS. Is there a way to make it run all the time, unless the app stops?

After the research, I guess the solution is implement beginBackgroundTaskWithExpirationHandler

and stops it by giving a handler and set location update on plist?

As for audio, besides setting the plist, anything else need to do to play audio?

Swift how to use NSTimer background? iphone - NSTimers in background Run app for more than 10 minutes in background

解决方案

No, in order to save all of us from apps that kill our batteries, Apple does not allow apps to continue to run in the background for more than a few minutes. There are only very special limitations (music playing apps, VOIP, navigation apps, etc.) which permit ongoing operation. In terms of details, this is described in Background Execution chapter of App Programming Guide for iOS.

If you want to notify user of something at some future time, you can use local notifications. When you do this, though, you don't control whether your app restarts or not. Only if the user taps on the notification (assuming they even granted your app notification privileges at all), will the app be reopened. For more information, refer the the local notification discussions in Local and Remote Notification Programming Guide. But note, this is not intended for alerts every 45 seconds, but rather for a significant notification scheduled for some future time.

For discussion of how one might marry local notifications with timers, see swift NSTimer in Background and this follow up question swift calculate time for timers running in background.

这篇关于使背景的iOS超过3分钟定时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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