背景中的计步器 [英] Pedometer in the Background

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

问题描述

我知道这已经被问到了 100 万次,但我无法弄清楚.

I know this has been asked 1 million times but it has been just impossible to figure it out for me.

所以我需要构建一个计步器应用程序并让它继续计算步数事件,如果他们将应用程序发送到后台超过 10 分钟.

So I need to build a pedometer app and have it continuing counting steps event if they send the app to de background for more than 10 minutes.

客户根本不想使用 GPS,也不想播放静音音频,因为 Apple 可能会拒绝它.

The client wants not use use GPS at all, an also not play a silent audio because Apple may reject it.

有人知道如何做到这一点吗?

Does anyone one have and idea on how to do this?

客户将 Runtastic Pedometer 应用程序作为参考,我一直在对其进行分析,它既不使用位置也不使用音乐,并且在后台运行超过 10 分钟.

The client is taking Runtastic Pedometer app as Reference and I have been analysing it and it doesn't use nor Location, nor music and runs in the background for more than 10 minutes.

有什么线索吗?这样做真的不可能吗?有没有可能 Runtastic 的人同意苹果使用一些秘密的 API 让它在后台运行?

Any clue? is it really imposible to do it this way? could be possible that Runtastic people made an agree with apple to use some secret API to have it running in the background?

推荐答案

我查看了 Runtastic Pedometer,它的 Info.plist 文件中有以下内容:

I looked at Runtastic Pedometer and it has the following in its Info.plist file:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>external-accessory</string>
</array>

所以基本上,他们做音频技巧,并声称与外部配件有一些搭配.

So basically, they do the audio trick, and they claim some tie-in with an external accessory.

我不想说出显而易见的事情,但您的问题似乎是这些是规则,但我不想遵守它们.我该如何绕过它们?"答案似乎是:向您的应用添加功能,直到您满足其中一项标准."来自文档:

I hate to state the obvious, but your question appears to be "These are the rules, but I don't want to follow them. How do I get around them?" The answer appears to be: "Add features to your app until you meet one of the criteria." From the docs:

在 iOS 中,只允许特定类型的应用程序在后台运行:

In iOS, only specific app types are allowed to run in the background:

  • 在后台向用户播放可听内容的应用,例如音乐播放器应用
  • 让用户了解他们的应用始终定位,例如导航应用
  • 支持的应用互联网协议语音 (VoIP)
  • 需要下载和处理新内容的报亭应用
  • 从外部配件接收定期更新的应用

因此,将其中一项功能添加到您的应用中.添加设置以在每走一英里后播放祝贺声.默认情况下将其关闭.这应该使您有资格获得音频播放豁免.可以选择捕获位置数据,以标记用户步行 1,000 英里时所处的位置.默认情况下关闭该功能.这应该符合位置标准.添加一项功能,可从 RSS 提要或 runnersworld.com 的头条新闻下载鼓舞人心的俳句.这可能会让您了解新内容的原因.这并不难.只需想出一些简单的、十行代码的功能,就可以让您入门.发挥你的想象力.

So add one of those features to your app. Add a setting to play a congratulatory noise after every mile walked. Leave it off by default. That should qualify you for the audio-playing exemption. Have an option to capture location data to mark where the user was when they crossed 1,000 miles walked. Leave the feature off by default. That should qualify for the location criteria. Add a feature to download inspirational Haiku from an RSS feed, or headlines from runnersworld.com. That might get you in on the new-content reason. It's not hard. Just come up with some trivial, ten-lines-of-code feature that gets you in the door. Use your imagination.

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

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