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

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

问题描述

我知道这已被问过100万次,但我不可能为我解决这个问题。

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

所以我需要建立一个计步器应用程序并且有如果他们将应用程序发送到de background超过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计步器应用作为参考,我一直在分析它,它不使用也不使用位置,音乐并在后台运行超过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计步器,它在 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)的应用程序

  • 需要下载和处理新内容的报亭应用

  • 从外部附件接收定期更新的应用

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP)
  • Newsstand apps that need to download and process new content
  • Apps that receive regular updates from external accessories

因此,请在您的应用中添加其中一项功能。每走一英里后添加一个设置以发出祝贺声。默认情况下将其关闭。这应该有资格获得音频播放豁免。可以选择捕获位置数据,以标记用户在行走1,000英里时的位置。默认情况下关闭此功能。这应该符合位置标准。添加一项功能,从RSS源下载鼓舞人心的Haiku,或者从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天全站免登陆