iOS - System Alert Location use in Background - ios

Sometimes I get an alert message, reminding me that my App is using the location service in the background.
If I read the Official Documentation, in the Give apps permission to use your Location section.
Other apps will ask for access to your location even when the app isn't in use. When you allow an app to always use your location, iOS will remind you which apps are able to use your location after an app uses your location in the background.
We can clearly admit that this alert will only be displayed when your App is using your location in the background.
So why am I asking this question ? Because this alert message just appeared when I woke up my phone, with no Apps in Background (all Apps were swiped up from the double tap Home button).
Does Background has other definition or maybe I am missing something?

Your app can be woken up (launched implicitly) by the system depending on the background modes it supports.
Even if you manually kill it in memory by swiping up, it still can be triggered in background if there is an incoming data for it to process (such as silent notification with payload).

Related

In swift, send User’s current location to server while app is killed

I am creating a Taxi Driver application in swift. I need to send the driver’s current location to the server by every 30 sec even app is killed. I found the solution while the app is in the foreground or background state. But I am not able to send location to server while app is killed. I tried with VOIP push and startMonitoringSignificantLocationChanges.
When the app is killed and VOIP push receives by every 30 sec, I can get the user’s location but, I am not able to call API and send a location to the server. Can anyone have a solution for sending data to the server while the app is killed?
Using startMonitoringSignificantLocationChanges while the app is killed I am able to send location to the server, but it takes 5 to 10 minutes to get user’s updated location while he/she is driving. I tried physically by traveling from one location to another location so many times. Apple doc tells that location updates when user’s position changes by a significant amount, such as 500 meters. But in reality, it updates by 5km to 7km traveling. Can anyone have a solution for it?
“If your app is terminated either by a user or by the system, the system doesn’t automatically restart your app when new location updates arrive. A user must explicitly relaunch your app before the delivery of location updates resumes. The only way to have your app relaunched automatically is to use region monitoring or significant-change location service. However, when a user disables the Background App Refresh setting either globally or specifically for your app, the system doesn’t relaunch your app for any location events, including significant change or region monitoring events. Further, while Background App Refresh is off your app won’t receive significant change or region monitoring events even when it’s in the foreground.” more...
App refresh is good idea but iOS allows only 35 to 40 seconds in background to wake up your app in background so you should call your functions in this period of time.. here is good example for location based background tasks Usage
and and and apple document says if you use silent push notification. However, the system does not automatically launch your app if the user has force-quit it..refer this

Background location iOS

I need to capture device location independently if app was killed, I have enable background modes location updates and background fetch also I have on app delegate the locationManager with startMonitoringSignificantLocationChanges. Currently I print each location update received.It works perfectly with app on foreground and when app is minimized, but when app is closed (double click Home button and remove) I dont receive updates. According to some forums and sites app should be called on background with each new location update but it dont works.
If the app is closed, it can't report location. The only thing that apps can do while closed is show notifications.
If the app is force closed by the user it will not be able to continue to update the users location in the background, there is nothing that works around this.
from the app life cycle documentation: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html#//apple_ref/doc/uid/TP40007072-CH2-SW6
In addition to the system terminating your app, the user can
terminate your app explicitly using the multitasking UI.
User-initiated termination has the same effect as terminating a
suspended app. The app’s process is killed and no notification is sent
to the app.

Identifying devices of users walking into a physical store and send messages

User has an iOS app in his device and he walks into a physical store. I would like to identify that user programmatically within the app and throw him push notifications like Welcome message and based on his usage history or his level, send him coupons etc., on entering the store. He has to receive these messages automatically. In what all ways this is possible? And most important thing is that this needs to work in all states of the app (foreground, background, not running, suspended). Appreciate any quick inputs here.
Since you tagged your question with iBeacon, here's a summary of what's possible with that technology. In general, you can do what you want, but there are some caveats.
If you install an iBeacon in the store and make the app look for that iBeacon using [locationManager startMonitoringForRegion: iBeaconRegion], your app will get a callback whenever that beacon is first seen. In this callback, you can make it send a local notification to the user (or by making a web service call, you can make it send a push notification to the user). This can happen in all of the app states you mention, using this definition of these app states.
The situations where this will not work is if:
The phone is turned off
Bluetooth is turned off
The app has never been launched since installation
The user has stopped the app from the task manager and has not restarted it since then
The user has denied the app permission to access your location
The callback to your app will happen as soon as the iBeacon is detected by the phone. This may be as far as 150 feet from the iBeacon if it is detected quickly. It is also possible that detection will be delayed by a few minutes until iOS enters its next Bluetooth LE scan cycle. Once the callback takes place, local notifications can take place immediately. Push notifications will probably have a delay of several minutes more.
The message you send to the user will show up on the lock screen, and if the user gestures to it, you can launch a specific part of the app.

Receive Notification of Battery State Change While in Background for iOS 7

So I'm building an app for iOS 7 which needs to display an alert automatically when the phone is plugged in to charge, even if the app is in the background.
The app also takes location into account, so I guess I can keep it receiving location updates. However, as far as I know, the app will stop receiving notifications about the battery state 10 minutes after it is put in the background.
Are there any suggestions as to how I can do this? I do not need to publish the app in the app store.
You can enable background fetch, and periodically check the battery state there. It's not as precise as you require, but this is the best you will get.

Other ways besides push to wake up an iOS app?

Has anyone created an iOS app reacts to events or triggers from external sources other than push (APNS)? For example, could an iOS app subscribe to a remote topic or queue? Or listen for HTTP or socket requests?
No.
Application could be launched if:
User tapped the icon
User selected the Push-notification/Local-notification
Application supports url-schemes and is launched while opening URL
Application supports view/edit of documents and user've selected your app to do this
If anyone has other ideas - feel free to edit or add comments.
App could run in background and have active http-connection/socket. But it couldn't be opened automatically.
In addition to user action and push/local notifications, an app can be woken by a significant location change, if the app has indicated that it wants to monitor such events.
See: CLLocationManager Docs
Look for a method called startMonitoringSignificantLocationChanges. If a significant location change occurs while your app is not in the foreground or isn't running at all, your application will be launched in the background, allowing the app to perform background-only operations (e.g. no view code will run).
The app will not launch into the foreground, however, if it is launched due to a significant location change.

Resources