8

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

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.

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?

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.

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?

Ben
  • 51,770
  • 36
  • 127
  • 149
Ecarrion
  • 4,940
  • 1
  • 33
  • 44

3 Answers3

21

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:

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 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

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.

ipmcc
  • 29,581
  • 5
  • 84
  • 147
  • Thank you very much, I will investigate further for the external-accessory. I would love to use the location the way you suggest, is just that the client doesn't why to use GPS, only god knows why. – Ecarrion Jul 22 '13 at 11:20
  • Following the rules means great app ideas get squashed. Thanks for this, now I have to figure out how to make this work for me. – Nathan McKaskle Jan 31 '15 at 17:39
  • This answer is very intriguing. Thanks for the research. Before jumping on to doing it, let me ask- if my app lets music playback from apple music during walk/run workout, will that suffice to allow background mode in my app for the reviewer? What if the user doesnt play music and pushes the app to background after starting workout? – AceN Mar 05 '21 at 13:59
  • And also, will the app wale to background from suspended unless music in being played from my app? If no, i can forget about giving percentage goal completec notifications for step goals. – AceN Mar 05 '21 at 14:01
1

You can check the Apple docs about Declaring Your App’s Supported Background Tasks. You can also check this tutorial about using the background modes.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • 1
    I know, I have read those documents like 10 times and according to them there is no legal way to do what I want, which I understand. But the client if obsessed that is possible because Runtastic Pedometer is doing it. – Ecarrion Jul 22 '13 at 10:49
  • Is it possible that Runtastic is using one of the above modes and you didn't realise? – Rui Peres Jul 22 '13 at 10:50
  • 1
    According to apple if you don't use those methods for a real purpose of the app will be rejected, also the App isn't asking for my location, is not playing music because I can use it while I'm playing my music, is not requesting bluethooth access, I'm not sure how to know if they are doing VOIP, but I don't think so because is not using the mic. So I'm out of ideas. – Ecarrion Jul 22 '13 at 11:00
  • What they ask in that thread is how to receive motion data while being in the background, I know that Core Motion is able to receive that while the app is in the background, the problem is how to maintain the app in the background so I can continue analysing the accel data. – Ecarrion Jul 22 '13 at 11:08
  • And if you read the answer, you will see that it's probably using location services. – Rui Peres Jul 22 '13 at 11:09
  • Well those are your solutions. Sorry if I can't you provide any more guidance. =/ – Rui Peres Jul 22 '13 at 11:11
  • Thanks anyway for your time, I just need to know if this is entirely impossible or anyone ones know how Runtastic Pedometer works. – Ecarrion Jul 22 '13 at 11:14
0

If you have a server side you can avoid running your app in the background by itself, by sending a silent push and waking up your app just for reporting the steps count.

You can register for silent pushes without having the user to confirm getting push messages since they don't see them.

Or Arbel
  • 2,965
  • 2
  • 30
  • 40