App "Alarmy" is able to play iTunes song from background state... How?
Asked Answered
M

2

7

I've been pouring over all documentation regarding background states and permissions for playing audio in iOS and I can't figure out how a particular app is able to seemingly wake itself at a specific time in the future and play non-bundled sounds. I'm looking into the issue because I'd like to add this functionality (like many others I've seen) to an app I'm building.

The app in question is "Alarmy" -- formerly "Sleep if you can." It's an alarm clock. Unlike most other alarm clocks in the app store, it is able to play an iTunes song as an alarm sound without being in the foreground at all. It can bypass the ring/silent switch, increase volume to max, and play a preselected song from a local iTunes library when it is seemingly (or should be) in a background state.

I don't know of any way to investigate what Alarmy is doing while waiting for an alarm time, but I can see that it does have location services enabled, cellular data enabled, and background refresh enabled. However, even with all of these turned off in settings, the alarm still works and plays an iTunes song! I have to assume as well that Alarmy isn't playing silence until the alarm time since it wouldn't have gotten through Apple's submission process (or could they just have missed this, and the playing field is now totally uneven).

It does have a feature that seems a little out of place -- the app displays weather information. This isn't necessarily complete fluff -- I can see some value in that for an alarm app -- but is it possible that they're querying some weather API at short enough intervals to keep the app awake in the background until the alarm time? If they are, what would that look like? Furthermore, weather APIs are free to use up to a certain number of queries, but they have a lot of downloads and I assume a lot of queries. For a fixed price paid app with no IAPs, that doesn't seem like a great business model.

So, to wrap up, IMHO, this feature can't come from any Background Audio permissions since the app isn't actively playing audio when it enters the background (unless its silence and they simply got lucky and slipped through the submission process); it may come from continually refreshing the app in the background for location/weather services (and then via a simple timer counting down to the alarm fire time) but the feature still works when background refresh and location services are disabled for the alarm. Could it be that the permissions are there, so even though the app isn't allowed to access the location information, the iOS still allows it to be active in the background?

One last thought: is there a silent push technique whereby they may be pushing a notification to the app at the time of the event and checking to see if it is time for the alarm tone to play? Shot in the dark there...

Any insight into the matter would help a ton! I'm pulling my hair out! I can edit this post and add more information -- i.e. what resources I've already looked at -- if you like, but I'm fairly certain that I've looked at every possible resource out there. Again, tremendous thanks for any help.

Monthly answered 2/4, 2014 at 21:10 Comment(3)
Don't know anything about iOS (Android guy), but isn't it possible to decompile this app? (jailbreak surely required). (it can be easily done in Android, but the code is generally obfuscated)Butterfield
Good call, xav. I haven't looked into doing that, but I will now. I guess I can jailbreak an older phone I'm not using anymore and see what I can discover. I'll look into it and post back any instructions for doing it (it'll be my first time). Thanks!Monthly
@BAinNOLA Did you figure out how the Alarmy app is able to play music when the alarm is triggered?Robinia
P
7

They're using the audio background mode, it's listed in their info.plist. They use the "NoSound.mp3" file in their bundle to play silence, while in the background. They also have a "Sleep music" mode to get them through the AppStore.

For other ways that you can use, check out this article.

Peristalsis answered 31/1, 2017 at 17:13 Comment(2)
can you explain what do you mean by "Sleep music" mode to get them through the AppStore." I also use music for sleeping, at background in my app. Do I need any tricks to get pass the app store?Mangle
webpage is nor reachableSponge
H
1
if ([[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying)
{
       NSLog(@"yes itune Player Sound is on");
}
else
{
      NSLog(@"NO itune Player Sound is not on");
}
Homolographic answered 7/4, 2015 at 10:21 Comment(1)
it goes to yes if your itune soud is on else it goes to no if sound is off of itune music player ... So You can chack easily default MusicPlayer Sound is On or Off You need to add mediaplayer Frameword Just Try It it will work Properly.... Thx...:)Homolographic

© 2022 - 2024 — McMap. All rights reserved.