iOS - show consistent alert at the top of the UI when backgrounding the app (like personal hotspot does) - ios

I am creating an alarm clock app that requires some user action within the app in order to turn the alarm off. Below is a picture of what another app, Sleep Cycle, does when you turn an alarm on and press the home screen (i.e. background the app).
Here is an image link (I can't post an image yet, no rep despite my many attempts to answer people's questions today) for the effect I want to re-create.
Those that have used iPhone's Personal Hotspot and connected a device will notice that it is the same effect, where a notification appears at the top of the UI - pushing everything down by around 20-40 points. This is highly desirable to an alarm clock app as it encourages the user to keep the app in the foreground so that the app can easily be entered when waking up (instead of relying on the 30 second sound window allowed by local notifications)
Does anyone have any ideas on how to implement this functionality. I assume that it must go somewhere in the:
- (void)applicationDidEnterBackground:(UIApplication *)application
tag within the AppDelegate, but I'm not sure what exactly I need to be reading up on. So if anyone has a link to some relevant Developer Docs that would also be extremely helpful.
Many thanks for your help,
Ryan

There are a handful of built in 'background modes' that change the status bar's appearance depending on what functionality an app provides whilst it's in the background. The one you've identified (a red status bar) is triggered when an app records audio whilst in the background. I presume Sleep Cycle must be acting as though it records audio just for this purpose. Other background modes include VoIP (which I think uses a blue status bar). Check out Apple's documentation on supporting these various background modes
In your case, you'd want to add audio to the UIBackgroundModes property in your Info.plist file.
But note that it wouldn't be unreasonable for Apple to reject an app during review if it pretends to perform one of these background tasks but doesn't. For example, there have been apps in the past that tried playing a silent audio clip continuously in order to stay awake in the background - needless to say Apple got wise to this and the app in question had to change its behaviour.

Related

Show advertisement at regular interval of time when iPhone is running

I am working on the app that shows Ads (Video or image) when iPhone is running. If I open any app(eg. Twitter) then also my Ads should be visible at particular interval of time. Is it possible to do so?
No. Your app will not be informed about any other apps being launched. Even if it were, you can't "force-grab" the foreground to display videos. That would totally violate any user interface principle established by iOS.
Besides the technical aspect I'd have my doubts of such an app surviving app review in general, though I don't know the specific part of the TOS right now.
It is possible to show your ads inside your application in intervals or in any pattern you like. However it is not possible to bring your app to foreground when in background to play ads, it is actually not recommended at all. Best thing you can do is set a timer when the app gets in background to send a notification.

Modify iOS view while app is in background or in multitask view

I am writing an iOS app that keeps and displays the state of a system. It basically shows a light whose color represents state:
green/yellow/red light <==> OK/warning/danger
I'd prefer to show accurate state even when the app is backgrounded, and its snapshot is viewed thru the iOS multitask viewer (the view that looks like a rolodex, which you get after double-clicking the home button). I REALLY don't want to show a snapshot which displays an inaccurate state.
So my question is: can you change the view (or perhaps the app snapshot) while the app is in the background, so that when it's viewed in the multitask view it shows an accurate state.
I've seen that this is not recommended by Apple: from App Programming Guide for iOS
Avoid updating your windows and views. Because your app’s windows and views are not visible when your app is in the background, you should avoid updating them. The exception is in cases where you need to update the contents of a window prior to having a snapshot of your app taken.
However, Apple's music app does just this...if you start playing a playlist, then put the music app into the background, the cover art gets updated as the music app works thru the playlist. So this functionality must be possible somehow.
The best answer I can come up with after a bunch of searching is to alter my app's view to the splash image prior to entering background operation. This would ensure that inaccurate state isn't displayed, but also prevents showing accurate state.
You can change the snapshot view immediately before the snapshot is taken (A banking app, for example might want to obscure personal information), but you cannot continue to update the snapshot from the background once your app is suspended. You may want to adopt this approach in order to avoid displaying an inaccurate state; show nothing rather than stale data.
You might also want to consider some other options, such as a "today" widget that contains the updated status or posting local notifications when there is a significant change in status (such as entering the "red" state).

Sleep Cycle - What kind of Backgroundmode is this?

I'm currently working on an app which reminds the user, when he gets to an certain location. I want this app working in background as well and searched for solutions.
In the AppStore i found the App called Sleep Cycle, which tracks your activities during your sleep. When you set the alarm, and running the App in the Background you get this screen red bar on the top of the Display of your iPhone.
http://i.stack.imgur.com/uEejp.jpg
Does anybody know what kind of Backgroundmode this is, and how i can transfer it to my app?
Thanks
To have such a red bar I use audio background mode and also I record sound in background. Since Sleep Cycle asks user to allow access to microphone I believe it also records audio in background

Changing the behavior of the iOS Lockscreen

Is there a way to change the behavior of the iOS Lockscreen? For instance, can an app, if active, provide a user with dynamic content, such as pictures, as the phone's background, and, in addition, allow a user to swipe left (in addition to swiping right, if they want to unlock the phone) to engage said content?
Is there a way to change the behavior of the iOS Lockscreen?
No.
For instance, can an app, if active...
No.
iOS doesn't provide any API that would allow the sort of thing that you describe. It might be possible to modify or replace the lock screen if you jailbreak your phone -- all bets are off at that point. But an app that uses the Apple-provided API has no way to modify the lock screen.
Also, note that if the device is locked, your app won't be active. You may have intended a looser definition of "active," but looking at the linked chart of app states will help you understand that what you're looking to do isn't achievable with the current API. Apps have to be active to receive events, but a locked phone implies that your app will be in an inactive, background, or suspended state if it's running at all.
No. (Not if you're talking about an 'app' in the sense of the App Store)
The only way an app can interact with the lock screen is through notifications, and cannot alter the standard lock screen interface.
You can alter the lock screen with a MobileSubstrate tweak on a jailbroken phone, but this requires reverse-engineering SpringBoard (the iOS launcher app), can be quite complicated and obviously cannot be distributed through the App Store

Monitoring Significant Location Changes, App closed GPS signal (Arrow)

First of all I hope don't repeat any topic, I have spent a lot of time reading on internet about this before ask.
I'm developing an app for iOS => 5 and I need get the user location, but I don't need always a great accurate position, so when the app goes to background I change the normal location mode to Significant Location Changes and when the app come to foreground I stop the significant location change mode and get back the normal location mode, that's all goes fine,
my problem is when the app goes to background mode or even the user KILL the app the GPS signal (the purple arrow) still appear ALWAYS, even after restart the device, the only way to make disappear it is un-installing the or disabling the significant location changes when the app goes to background, but I need this mode working when the user goes to background mode, maybe not when the app is killed.
I don't know how to stop the service when the user kill the app... because event "applicationWillTerminate" is not called if you have multitask ON.
My main reason because I don't want the purple arrow appear always, even the app is killed is because I don't want the user think the app is drying the battery... so the user won't want the app installed.
First question: Is normal that the purple arrow appear always, even the app is killed if the Significant location change is enabled for the app?
Second question: Is any way to change this, to stop the service at least when the app is killed to hide the purple arrow?
Thank you all.
Sorry for my english if something is wrong.
After few days researching to be sure about this service, seems like there is NO way to use significant locations change in the background without the arrow in the top bar. I have been testing with different apps and reading through internet and nothing to solve this.
The only ""way to solve"" this is disable multitask mode in the app and disable the significant locations change in the event "applicationWillTerminate" but don't make sense... I'm losing the background location always not only when the app is killed... so is not useful.
It's bad... is a really good service to get locations saving battery but as user and developer I don't want an app that make appear this icon ALWAYS even after the app is killed, as developer I don't want that people uninstall the app for this reason and as normal user I don't know what mean this icon if is normal GPS or Significant locations change and what mean this... if my battery is being drain or not.
The other option to get locations in background task but has a big impact over the battery....
I hope apple fix this in future versions... adding at least a new arrow or showing only when a new location arrive instad of always or allowing to stooped when the app is killed.
All this has been researched over iOS - 6.1
Thanks to all.
When you use the significant location change service, the OS keeps your app running. If the app is in the background and is killed, the OS restarts it, so the purple arrow will always show. When a new location is detected, the app is restarted. From the docs:
If you leave this service running and your app is subsequently suspended or terminated, the service automatically wakes up your app when new location data arrives. At wake-up time, your app is put into the background and given a small amount of time to process the location data. ... To stop the significant change location service, call the stopMonitoringSignificantLocationChanges method.
Hmmm, interesting. I've just seen that problem with another app - seeing the arrow still active made me want to disable location updates for that app so the problem is real. Best thing I can think of is to have some kind of timer to disable the location monitoring after a certain amount of time if that is appropriate for your app.

Resources