iOS的背景模式 [英] iOS Background Mode

查看:148
本文介绍了iOS的背景模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在后台运行的应用程序的问题。
我知道如何做到这一点,但苹果不喜欢我做的方式。

I have a question about running an app in the background. I know about how to do it, but Apple does not like the way I'm doing it.

为了让你在同一页上,我有一个安全的应用程序,我需要把它监控设备即使是在后台。这有点像一个防盗报警器。
我使用的背景音效模式,认为它会好起来的,因为我会打一个声音就被触发时。不用说,苹果不喜欢这一点。
所以我增加了一个平!它执行ping而活跃,为此播放背景音乐,同时在后台运行。
再次,他们不喜欢。

To get you on the same page, I have a security app, and I need to it monitor the device even when it is in the background. It is sort of like a burglar alarm. I was using background audio mode, thinking it would be okay because I will be playing a sound when it is triggered. Needless to say, Apple didn't like that. So I added a ping! It pings while active, therefor playing background audio while in the background. Once again, they didn't like that either.

我的应用程序监视加速计,以及(但不总是,仅当由用户选择)。

My app monitors the accelerometer as well (but not always, only when chosen by the user).

我的问题是,你怎么样的应用程序,例如Skype和其他类似的应用程序能够把状态栏红色,而留在后台? (即使有人报警的应用程序将做到这一点,而不播放任何音频或其它)。

My question is, how are apps like Skype, and other similar apps able to turn the status bar red, and stay in the background? (Even some alarm apps will do this, without playing any audio or anything).

另外,我无法使用通知系统,因为如果我监测电池电量不更新速度不够快。对于我的应用程序,我需要即时响应。

Also I can't use the notification system because it does not update fast enough if I'm monitoring the battery level. For my app I need immediate response.

我也四处寻找不知疲倦地为这个答案之前,我贴我的问题(我已经找到答案,不要为我工作..):(

I have also searched around tirelessly for this answer before I posted my question (the answers I have found, do not work for me..) :(

我将不胜AP preciate这个任何见解,在此先感谢!

I would greatly appreciate any insight on this, Thanks in advance!

(如果你不再需要的信息,请咨询!)

(If you need anymore information, please ask!)

推荐答案

从我可以从他们的文档出来,似乎就可以保持一个持久的后台连接的唯一方法是通过使用的七<一href=\"http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html\"相对=nofollow>后台模式键,我可以看到你一直在努力,因为你注册的背景音乐。我知道有人报警应用程序,以及使用此功能(如睡眠周期),和我的假设是,他们也使用背景音乐模式,综合考虑其他六个模式并不远程接近他们会需要它。

From what I can tell from their documentation, it seems that the only way you can maintain a persistent background connection is by using one of their seven background mode keys, which I can see you've been trying since you registered for background audio. I know some alarm apps as well that use this feature (e.g. Sleep Cycle), and my assumption is that they are also using background audio mode, considering the other six modes are not remotely close to what they would need it for.

我觉得苹果的理由可能是这些应用程序都允许这样做,是因为他们的应用程序被设计为当用户不使用手机主动(即当他们正在睡觉)使用,并需要将音频唤醒用户了,而如果你正在运行要活跃在任何时候都安全应用程序,它可以与其他功能,用户可以使用Skype等干扰。红色条也将在任何时候该装置的顶部仍然存在,当用户在使用它,这时候一个红色栏出现就意味着给用户,他们仍在积极使用他们可能误以为的东西,因为通常是仍在播放一些东西。同样,我想叫醒报警器的应用程序和其他类似的未使用持久音频能与此脱身,因为他们是专为使用的时候,手机是无效的,因此具有持久的红色条时,应用程序是不是可见的是不再是一个问题。

I think Apple's reasoning might be that these apps are allowed to do so, because their app is designed to be used when the user is not using the phone actively (i.e. when they're sleeping), and requires the audio to wake the user up, whereas if you are running a security app that wants to be active at all times, it may interfere with other features the user may use like Skype. The red bar will also persist at the top of the device at all times when the user is using it, which they may mistake for something that is still playing since usually when a red bar appears it means to the user that they are still actively using something. Again, I think wake-up alarm apps and others like them that aren't using persistent audio are able to get away with this since they are designed for use when the phone is inactive, so having the persistent red bar when the app is not visible is less of an issue.

在其他一些情况下,像耐克+(讨论<一个href=\"http://stackoverflow.com/questions/8716466/how-nike-gps-on-iphone-receives-accelerometer-updates-in-the-background\">here)并有可能计步器,他们似乎使用位置背景模式,因为它们往往还跟踪你在哪里,并且需要知道的距离。在讨论我的联系,它看起来像其他人能够通过一个后台注册来获得加速更新模式,它适用于他们。你试过报考所在地的动作?一个缺点,我可以看到这就是它可能会消耗电池寿命更快,但如果你检查的位置很少,可能不会太糟糕?另一个原因是,我不认为您可以直接在后台位置模式下播放音频,但你可以尝试触发声音通知?:)这可能是它一个很好的解决方法是否适合你的应用程序。

In some other cases, like Nike+ (discussed here) and likely pedometers, they seem to be using the location background mode, since they often also track where you went and need to know distance. In that discussion I linked to, it looks like others were able to get accelerometer updates by registering for a background mode that applied to them. Have you tried registering for location movements? One downside I can see to that is it might drain battery life quicker, but if you check location infrequently it might not be too bad? Another is that I don't think you can directly play audio when in location background mode, but you could try to trigger a sound notification? :) That might be a nice workaround for it if that works for your app.

再次推理我为什么这些应用都能够做到这一点正是基于如何我见过的其他应用程序运行,而苹果可能对为什么他们接受不同的原因,但是这是我最好的方式想为什么你的应用得到了拒绝使用这些模式,而其他人能够做到这一点。如果位置是不是你要找的东西,可惜我不是这听起来像你的应用程序是这样做,你可以在你希望的方式在后台持续运行它肯定。

Again, the reasoning I have for why these apps are able to do it is just based on how I've seen other apps operating, and Apple may have different reasons for why it accepts them, but that was my best way of thinking why your app got rejected for using those modes while the others are able to do it. If location isn't what you're looking for, unfortunately I'm not sure from what it sounds like your app is doing that you'd be able to operate it continuously in the background in the way you're expecting.

这篇关于iOS的背景模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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