After IOS8, the program does not receive a hint that the application calls the system service, and needs to make changes before using the location method.
In IOS8, there are two uses for positioning, one is to access the user's location information when using the app, and another is to allow access to the user's location when the application is not in use.
The code is as follows:
Self.locationmanager = [[Cllocationmanager alloc] init];
if ([[Uidevice currentdevice].systemversion Floatvalue] >= 8.0) {
[Self.locationmanager requestalwaysauthorization];
You need to add the default field "Nslocationalwaysusagedescription" to the plist file, which is: "Allow the application to access your location when you are not using the application?" The value of the nslocationalwaysusagedescription is to tell the user what to use for targeting or a tag.
[Self.locationmanager requestwheninuseauthorization];
The default field "Nslocationwheninusedescription" needs to be added to the plist file, and the prompt is: "Allow the application to access your location when you use the application?" ”
}
Self.locationManager.delegate = self;
Self.locationManager.desiredAccuracy = Kcllocationaccuracybest;
Self.locationManager.distanceFilter = 1000.0f;
[Self.locationmanager startupdatinglocation];
Local notification: After IOS8, the method of local notification used before, the user can no longer receive the system prompt, need to create a local notification when the registration, the code is as follows:
Initialize a local notification
Uilocalnotification *localnotification = [[Uilocalnotification alloc] init];
Set the time for local notifications
NSDate *firedate = [NSDate datewithtimeintervalsincenow:10];
/* The following lines of code are required to be added
Uiusernotificationsettings *settings = [Uiusernotificationsettings Settingsfortypes:uiusernotificationtypebadge | Uiusernotificationtypesound | Uiusernotificationtypealert Categories:nil];
[[UIApplication Sharedapplication]
Registerusernotificationsettings:settings];
*/
Registration Notice
[Application schedulelocalnotification:localnotification];
IOS8 Positioning method