Get Core Motion Updates when app is in background - ios

I am building a location based app. But, when my app is in the background, location updates continue and it drains the battery. So I chose to use Core Motion to detect if user is in Automotive mode, and only use Core Location if that is the case, and not update locations otherwise. But the Core Motion chip sleeps in background mode and I don't get data.
How can I keep the Core Motion chip awake while my app is in the background?

Related

Run small algorithm while iOS app is in background

I am developing an iOS app kind of similar to functionality of Apple's air tag tracker app.
My app doing dead reckoning using CMPedometer and Accelerometer. Dead reckoning should start after receive a accurate gps location (I have enabled Location updates background mode)
There are some calculations execute at the same time to measure walking distance, calibration algorithms to dead reckoning and communicate with the target object via bluetooth once the user(app) is in communicating distance with the object.
In this case, target object act as Bluetooth central and App act as the bluetooth peripheral. So, I have enabled Acts as a Bluetooth LE accessory background mode as well.
Currently I have implemented the dead reckoning and calibrations. App working in the foreground. But the main requirement is to work in background also.
I have read few articles and documentation about iOS background modes and it seems very restricted to execute algorithm.
My intention is to start dead reckoning and algorithm based on a trigger from gps or bluetooth device.
At thing moment, I still haven't implement any codes for background processing, more of a feasibility study at the moment. As per my understanding Background fetch and Background processing both scheduled by the iOS, so these two ways will not help. Possible ways could be act upon a bluetooth trigger, act upon a location update or background push. Highly appreciated your thoughts on these approaches.
https://developer.apple.com/forums/thread/685525
https://developer.apple.com/videos/play/wwdc2020/10063/
https://developer.apple.com/documentation/xcode/configuring-background-execution-modes

Getting Location updates only from Apple Watch (even when an iPhone is connected)

Is it possible to always use the GPS chip in the Apple Watch for a WatchKit app, even when a iPhone is connected (for Apple Watch series 2 and above because these models have a GPS chip on board).
For my app on watchOS I need the most accurate GPS data. Unfortunately, when an iPhone is connected location request (using the standard code) are delegated to the iPhone and the GPS chip of the iPhone is used. This makes perfectly sense from a power conservation perspective, but not from an accuracy perspective. The iPhone could be tucked away in a coat, bag etc. In that case the phone has no clear view to the sky, while the watch has. The GPS data from the watch are much, much more accurate in that case (and the iPhone GPS data extremely inaccurate)
Is there a way to configure the CLLocationManager to block delegation of GPS location requests to the iPhone and always use the GPS chip in the watch?

iOS Geofencing; will this be more accurate than what I have now?

I am by no means an iOS developer, and am just hacking something basic together for myself. Sorry if this is too beginner of a question.
I'm trying to collect my own location data from my phone to my own back-end service. Looking around, I found a sample project to collect location info: https://github.com/chriseidhof/PostGPS/
From the looks of things, this project uses significant location update, so even though I changed my desired accuracy to 100 meters, the app will still only provide update when enough cell towers have changed.
Instead, I'm thinking of using geofencing (CLCircularRegion) by creating grids of 3x3 geofences with 500 meter radius (with maybe a 50 meter overlap between each region), and each time I exit the central region, a new set of 3x3 geofences gets generated.
My questions are as follows:
Is this (the deleting and re-fencing part) a correct use of geofencing on iOS?
Is this going to be more accurate than what I currently have?
Will this significantly negatively affect my battery life?
The problem with using geofencing is that you can't monitor more than 20 regions at a time(OS limitation). It's better to use significant location changes. It is triggered while you're in foreground or background and the location is updated if the cell tower has changed or you have opened the app while the app was not in memory. But this method will be triggered only in the intervals of 15 mins. So even if the cell tower changes rapidly, this method will be invoked only once in 15 mins.
So if you want to update the location in background keeping in mind the battery usage as well, use significant location api.

iBeacon to detect accessory proximity (whilst app in background)

I would like to use iBeacon to detect the proximity to a hardware (emitting iBeacon signals) when the app runs in background.
Is there a way to get CLLocationManager to detect the location/proximity to an iBeacon whilst the app is running in background?
Does using iBeacon affect the iOS battery performance in a variable way depending on the transmission frequency of the iBeacon hardware? In other words, if we have an iBeacon that has a high transmission frequency will the iOS device drain more battery as it will be receiving more signal than when using an iBeacon with a lower transmission frequency?
Technically, it's possible to force ranging (estimating proximity) in the background on iOS. The problem is, that it has big impact on battery and potential user privacy implications, so it's unlikely that Apple would accept such an app into the App Store.
The proper (as in recommended by Apple) way for an app to interact with beacons in the background, is with region monitoring: simply detecting whether the user is in range of a beacon. If you want to force background ranging though, there's a short guide for that: https://community.estimote.com/hc/en-us/articles/203914068-Is-it-possible-to-use-beacon-ranging-in-the-background-
Cheers.
There are two different ways to use iBeacons - checking for region changes, or checking proximity to beacons.
In the background, you can't poll a beacon for proximity directly, you must instead use startMonitoringForRegion: to monitor for the crossing of the region boundary. Once that boundary is detected, your app will wake up to process in the background and handle what you want it to handle.
The application:didFinishLaunchingWithOptions: dictionary contains a key that indicates your app was launched due to a location event.
The transmission frequency of the beacon only affects the battery life of the beacon.

detect the motion of the device in vehicle in iOS

I have a requirement like the motion of the device in vehicle while driving should be detected when the application is in background. When the motion is detected the app should start automatically and move to foreground from background in iOS 7. I read that it is possible using CMMotionActivity Manager but have no exact clue to implement this functionality.

Resources