Most of the apps are being rejected by the App Store with the saying “Background Services have not been used properly”. As a developer, it’s our responsibility to furnish the apps with the required services efficiently in an appropriate manner.
To access the Location services, we need CoreLocation Framework to be linked with our application.
Determining the need of Location Services in Application
For using Location Services properly in our app, we have to include UIRequiredDeviceCapabilities key in info.plist file. The reason for adding UIRequiredDeviceCapabilities key is to specify the requirements of our app to be installed in any iOS device. So that App Store will prevent users from downloading apps in the devices which are not having the listed requirements.
The features that UIRequiredDeviceCapabilities (array of strings) are
#1. Location Services: We can add this string for using Location Services generally.
#2. GPS: We can add this string when our application requires accuracy offered by GPS hardware.
Getting User’s Current Location
The CoreLocation Framework helps to locate the current Location of the device and use that information in our application.
The services that help to get the user’s current location are:
#1. The Standard Location Service.
#2. The Significant-Change Location Service.
Starting with Standard Location Service
This is a general service for getting location data and tracking location accurately. We can configure the desired accuracy of the location data in our application.
For using this service, we have to create an instance of the CLLocationManager class and configure its desiredAccuracy and distanceFilter properties. To begin receiving location notifications, assign a delegate to the object and call the startUpdatingLocationmethod.
If a location update has already been delivered, we can stop Location updates by calling stopUpdatingLocation.
If Location services in background is a must for our application and to maintain good battery life for user’s device, we have to set location manager’s pausesLocationUpdatesAutomatically to YES. Then CoreLocation pauses location updates when the user is not moving anywhere.
When the location manager pauses location updates, it notifies its delegate object by calling its locationManagerDidPauseLocationUpdates: method. When the location manager updates, it calls the delegate’s locationManagerDidResumeLocationUpdates: method. We can use these delegate methods to perform tasks or adjust the behavior of your app.
Starting Significant-Change Location Service
This service is a power-saving alternative service to the Standard Location Service. This service uses Cellular data or Wi-Fi to determine the user’s location. The significant-change location service can also wake up an iOS app that is currently suspended or not running in order to deliver new location data.
To use the significant-change location service, create an instance of the CLLocationManagerclass, assign a delegate to it, and call the startMonitoringSignificantLocationChangesmethod.
Apple Issues and Appropriate Solutions:
Issue 1: We found that your app uses a background mode but does not include functionality that requires that mode to run persistently. This behavior is not in compliance with the AppStoreReviewGuidelines.
We noticed your app declares support for location in the UIBackgroundModes key in your Info.plist but does not include features that require persistent location.
It would be appropriate to add features that require persistent use of real-time location updates while the app is in the background or remove the “location” setting from the UIBackgroundModes key. If your application does not require persistent, real-time location updates, we recommend using the significant-change location service or the region monitoring location service.
For more information on these options, please see the “Starting the Significant-Change Location Service” and “Monitoring Shape-Based Regions” sections in the LocationAwarenessProgrammingGuide.
You can include the functionality and methods for the location services if your app needs Location services or remove the Location Updates from UIBackgroundMode key in plist, So that your app will be approved by App store.
Issue 2: we found that your app uses a background mode but does not include the following battery use disclaimer in your Application Description:
“Continued use of GPS running in the background can dramatically decrease battery life.”
If we want to use Standard Location Services continuously in foreground or background, we have to mention in the app description that “Continuous usage of GPS will makes the battery to dry”. So that your app will be approved by App store.
Readers like you help support iGeeksBlog. When you make a purchase using links on our site, we may earn an affiliate commission. Read Disclaimer.