geofencing no longer relaunch app from terminated state in ios7? - ios7

I'm developing an app which uses ibeacon to determine if the user entered a specific region.
Now I'm using the CoreLocation framework to implement this geofencing-based feature.
I've read the document below.
https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html
in which the Apple is saying that:
"In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so that it can process the event. When relaunched, all of the regions you configured previously are made available in the monitoredRegions property of any location manager objects you create. "
I discovered that it's true just before the ios 7.
From ios 7, An app will be waken-up from background but it will actually no longer could be re-launched from terminated-state (slided out from the task manager which displayed by double-clicking the home button).
If it's due to the Apple's policies, why does Apple not update the above official document?
So I'm thinking of an ios7's bug because the Reminder App (a built-in app) is also not relaunched in ios7 even though it's relaunched in ios6.
Is this issue due to Apple's policies? or an ios7's bugs?
It takes me more than 2 days to google for a solution.
Any ideas for this issue?

The documentation is simply out of date. This is intended behavior in iOS7. Apple produced a video explicitly discussing this change. The idea is that if the user explicitly terminates the app, the user does not want it running. See this thread.
Is this such a big deal? How often will users really do this? Remember, if users are annoyed by you app, they can always uninstall it, too. This was true in iOS6.

iOS 7.1 reversed this policy. That is even if the user kills your app the iOS still launches your app upon crossing the region.

Related

No longer receiving iAd revenue or requests?

I have a few applications on the App Store that have iAd banners. One of my applications no longer displays iAd banners anymore. I have not updated the application or anything. Fill rate, requests etc. are all displaying 0. I do have the Live Ads status for the application.
Any ideas as to why this is happening and how I could solve this issue?
Are these applications older applications? I read somewhere recently, going to try to find it, that applications that use static launch images, only support a few older screen dimensions (iPhone3/4/5), and are required to be stretched to meet the newer screen dimensions (iPhone6/6+) will not receive iAd banners. Implementing Auto Layout, and using a LaunchScreen.storyboard in your application should fix these issues.
I have not tested this extensively but all of my older applications that fit the example I've given have stopped receiving iAd banners. My newer applications that implement Auto Layout, use a LaunchScreen.storyboard, and are universal receive iAd banner advertisements just fine.

Background modes are turned off automatically

I have set in the Info.plist, the "app require background modes", the "app registers for location updates".
I put the app to be in the background, and I do get the location delegates for a while, but after 25 minutes it stopped getting the locations.
How do I know that? Each call of the delegate, it sends the data to the server (parse) .
I am also wondering if the problem arises because the location is turned off in the background, or because I can't send data to the server at background.
Also do I have to turn on audio to keep it alive?
According to Apple, I can listen in the background with:
apps that play audible content to the user while in the background, such as a music player app
apps that record audio content while in the background
apps that keep users informed of their location at all times, such as a navigation app
apps that support Voice over Internet Protocol (VoIP)
apps that need to download and process new content regularly
apps that receive regular updates from external accessories
Do I have to turn on an audio? Our app needs to get data location constantly from business.
This issue is amazing. There are dozens of opinions about what you can do and what you can't do. There is no one place that tells you how you can sample background locations, and if Apple allows this.
I guess problem is with pausesLocationUpdatesAutomaticallyBy
By default LocationManager pausesLocationUpdatesAutomatically is Yes, so after some if your device is not move or not change location may OS will stop the app, so set NO for this property , and not need to turn on an audio.

iOS7: Control center, remote-control, and CoreAudio audio session solo-ambient category

Before iOS7 came, we noticed an issue:
Music remote-control from earbud or springboard can hijack our audio session even if we set the category to solo-ambient or another exclusive mode.
We thus tried a few things:
We tried to take ownership of the audio session back. But this requires that our audio code knows when to take it back and from whom. We thought we could let the app code become the first responder to remote-control events, do our stuff, and then pass the events on to the music app. However, we found that the events got detained by the first responder and there is no way to push it back to the chain of commands.
We tried to become first-resonder and block remote-control events all together when we are in solo-ambient. This worked fine with iOS6, still works with earbud control in iOS7, but fails with iOS7's control center. The control center seems to bypass the remote-control event handler remoteControlReceivedWithEvent completely, where we put our blocking code.
I read something elsewhere that:
You can't block the music app. your app can become one though (apple
won't like that) and then the control center would control yours.
But I found no documentation whatsoever about control center.
And as said above, control center does not enter the normal remote control hooks even if an app is the first responder.
Another quoteP
Remote Control Event handling is so your app can be controlled by
Control Center, the earbuds, etc... it is not so that your app can eat
said controls, preventing control of other apps from said sources. It
only worked in iOS6 because of a bug in iOS, now fixed in iOS7
Is it that what had were using was due this bug? I find it hard to believe because we got the solution on this list and the Xcode mailing list so I assume that was an accepted solution.
Now we really wonder if we are missing something from the very beginning:
Is solo-ambient really an exclusive mode for audio session or is it that music app is an exception to that exclusivity?
How can our app live in harmony with the remote-control, and control center?
Where can we find up-to-date documentation of remote-control and control center?
The remote control has been mysteriously fixed after clean building everything agains iOS7 SDK. Now app delegate can receive remote-control events from Control Center. However, the play/pause events are UIEventSubtypeRemoteControlPause and UIEventSubtypeRemoteControlPlay instead of the iOS6's UIEventSubtypeRemoteControlTogglePlayPause.

Detect shake event in app background iOS7

This was always impossible in iOS6 and below however with the new multitasking API's etc in iOS7 I was wondering if it has become possible. I am developing an app that is for personal security... The user needs to be able to trigger an "an" inside of the app when in background mode... The shake function would be the best approach however so far it seems impossible..
Any help would be greatly appreciated. T
The background tasking feature is not what you think. Apple heavily regulates it's use. You're probably thinking of the new iOS 7 background feature called "Background fetch". You can count on being activated for partial background execution as a batch job every few hours.
The new background fetch feature is to be used when: "The app regularly downloads and processes small amounts of content from the network."
This will let you update the state of your app in the background so that the new iOS 7 multitasking feature lets you see an updated state of the app in that view. There is no iOS 7 background state that does what you want.

Confusion between background vs suspended app states

I am bit confused about these two states. Following is my understanding;
when app is in background and if you have "Application does not run
in background" set to NO in App plist file then App continues running
in background. In suspend mode App stays in memory but does not
execute code! System doesn't notify App when it moves to Suspended
state and wipes out App from memory in low memory situation to create space for foreground Apps.
Is my understanding correct? If it is so then why don't I get my NSLog printed on console when App running in background and executing code? What actually happens to my TCP socket connection where I am continuously gets the data from server? Why do we need Suspended state as anyway System eventually wipes out App from memory in low memory situation. Is there any difference between App becoming active from suspended state or starting fresh?
You should look in the IOS App Programming Guide section "App States and Multitasking".
Find that by searching the Xcode documentation with the phrase "App States and Multitasking" and "Hits Must" item set to "Match Search Term". Another useful search phrase: "background execution".
The summary answer is that an application can continue "executing" in the background indefinitely for only a limited number of reasons:
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
Aside from those specific operations, an app can ask to continue to execute for a very short time which the documentation covers in the section "Executing a Finite-Length Task in the Background". After a short time either your app tells the system it is done (and is then suspended) or it is forcibly terminated. Details in the doc.
Another useful bit of that document, with nice state diagrams, is the section "Managing App State Changes". That section talks about going into the background and returning to the foreground. It should answer your question about the difference between starting fresh versus starting from the suspended state. The short (not quite correct) answer is that if you start from the suspended state and you don't take any special actions when entering the background or (re)entering the foreground then you just continue more-or-less from where you were. Also, starting from the suspended state is faster. Read the doc since it says it much better than my paraphrase would.
App State
Not running: Your app is in this state before it starts up.
Active: Once your app is started, receiving events.
Inactive: When your app is running but something happens to interrupt it, like a phone call, it becomes inactive. Inactive means that the app is still running in the foreground but it’s not receiving events.
Backgrounded: In this state, your app is not in the foreground anymore but it is still able to run code.
Suspended: Your app enters this state when it’s no longer able to run code.
Background:
Executing code - Code is executed while the app is in a background state.
An app must go into a background state before it can go into a suspended state.
ie. Suppose you're on Facebook and you upload a video and you quickly switch to another app immediately after pressing the POST button. Although you switched to another app w/o terminating the app, the app can be configured to perform background processes to complete the upload.
An app that is in background does not necessarily mean it is suspended but an app that is suspended is in background.
An app can request to stay in background mode for extra time (for purposes of playing audio in the background or completing a network request, for example); afterward it will either go to suspended state or it will be forcibly terminated by the system.
Suspended:
Not executing code - Code is not executed while the app is in a suspended state.
An app that is in a suspended state is also in a background state.
The system moves apps to this state w/o notifying you beforehand.
An app in a suspended state is still in memory.
Some additional information that may help you on this topic:
UIApplication notifies the app of state transitions through methods in the AppDelegate.
Most state transitions are accompanies by these methods.
These methods are part of the UIApplicationDelegate protocol.
They provide you with a chance to respond to state changes.
The method below, for example, tells the delegate when the app is about to terminate. - It's only called if the app's in background before being terminated; not suspended.
func applicationWillTerminate(_ application: UIApplication) { ... }
In addition to Charlie Price's answer from 2013, iOS now also allows background for:
REMOTE NOTIFICATIONS that signal there is new content available for download. When a remote notification arrives, the system launches or resumes the app in the background and gives it a small amount of time to download the new content.
CORE BLUETOOTH to communicate with a bluetooth accessory while in background.
Click here for more details
UIApplication.shared.backgroundTimeRemaining tells you how many seconds is remaining until the system terminates the application. 3 minutes is the maximum time limit, but this time restarts each time the app is woken up in background mode.
You can prevent your app from ever entering a background or suspended state & instead immediately terminating by setting the UIApplicationExitsOnSuspend key to YES in the info.plist.
Additional links you may find useful:
https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
https://developer.apple.com/documentation/uikit/core_app/managing_your_app_s_life_cycle/preparing_your_app_to_run_in_the_background/about_the_background_execution_sequence
https://medium.com/#abhimuralidharan/finite-length-tasks-in-background-ios-swift-60f2db4fa01b
https://qph.fs.quoracdn.net/main-qimg-473264d5d9f0ec16d57b8dffcc9824d8