IOS8 Background Location test environment
Xcode6.3.2, simulator version system 8.3, real machine system version 6.1.3
Test conditions
- Set Backgroundmodes, use Requestwheninuseauthorization to get Permissions
- Set Backgroundmodes, use Requestalwaysauthorization to get Permissions
- Do not set Backgroundmodes, use Requestwheninuseauthorization to get Permissions
- Do not set Backgroundmodes, use Requestalwaysauthorization to get Permissions
Test Note: In the process of discovering the use of both requestalwaysauthorization and requestwheninuseauthorization to request permission, the app takes precedence over the pre-order requests and ignores the latter. For example, use:
[_manager requestWhenInUseAuthorization]; [_manager requestAlwaysAuthorization];
After installing the app, the pop-up box is requestwheninuseauthorization, and access to the system "settings--privacy--and location" is only for use. Therefore, the test code refers to the test of a single statement.
Configure Test Engineering
Create a new test project called Backgroundlocation, find the backgroundmodes in the Targets->capabilities, click on to select the location below Updates. The option to turn this on and off will be tested later in the test.
Test conditions 1
To install the app, the system prompts:
Click Allow and the system starts typing the print log:
The program is minimized to the background of the latter lock screen, still have a printout. However, the system will be as prompt, and the navigation bar will change color when the screen is locked:
Test Conditions 2
To install the app, the system prompts:
Click Allow to start typing the print log. Minimize the program to the background or lock screen, still have the printout, but the system interface is all right, there is no condition 1 hint.
Test Conditions 3
The System prompt box is the same as condition 1, but no more printout after minimizing and locking the screen, indicating that no further positioning is performed after entering the background.
Test Conditions 4
The System prompt box with the condition 2, but the minimum and the lock screen still have the printout, the system interface is all normal, there is no privacy reminder in condition 1.
Test summary
- The phenomenon of condition 3 and condition 4 can infer that nslocationwheninuseusagedescription is available only when the user is using the app. This is available when the app is active. The nslocationalawaysusagedescription can also continue to be positioned after the app has entered the background.
- By the phenomenon of condition 1 and condition 2, it is possible to infer that iOS is really strict with user privacy control, and Backgroundmode ensures that even nslocationwheninuseusagedescription applications can be positioned in the background.
But by comparing condition 2 and condition 4, it seems that there is no difference between the two, what is the use of Backgroundmode?
In the Official document (https://developer.apple.com/library/prerelease/ios/documentation/iPhone/Conceptual/ IPHONEOSPROGRAMMINGGUIDE/BACKGROUNDEXECUTION/BACKGROUNDEXECUTION.HTML#//APPLE_REF/DOC/UID/TP40007072-CH4-SW1) I found such a passage:
Enabling this mode does not prevent the system from suspending the app, but it does tell the system that it should wake up the app whenever there is new location data to deliver. Thus, this key effectively lets the app run in the background to process location updates whenever they occur.
Open uibackgroundmodes-location updates does not prevent the system from suspending your app, but it tells the system to wake up the app when a new address location is updated, in such a way that your app can handle location updates whenever you want.
But, however, the simulator test has not been successful and waits for the real machine to be tested.
Continue to consult the documentation: https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/ LOCATIONAWARENESSPG/CORELOCATION/CORELOCATION.HTML#//APPLE_REF/DOC/UID/TP40009497-CH2-SW1:
//Using the Standard Location Service in the BackgroundThe system delivers location updates to background location apps when the app is in the foreground, is running in the background, or is suspended. In the case of a suspended app, the system wakes up the app, delivers the update to the location manager’s delegate, and then returns the app to the suspended state as soon as possible. While it is running in the background, your app should do as little work as possible to process the new location data.
Https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG /CORELOCATION/CORELOCATION.HTML#//APPLE_REF/DOC/UID/TP40009497-CH2-SW8:
Note: 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 the significant-change location service.
Note: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!!!
The simulator is still not tested successfully. Success stories!! Success stories!! Success stories!!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
IOS8 background positioning