Declaring features that require persistent location

Hi everyone,


Would really appreciate your help figuring out where to declare the features that require persistent location. Thanks





Additionally, your app declares support for location in the UIBackgroundModes key in your Info.plist file but does not declare any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location.


The application uses location persistent in foreground. There are configured in plist files. (Please see the image bellow).


The application uses a method for sending data. There are used for statistical data in back office and for push notification services.


The flow is simple: user interacts with a beacons, based on location and beacons Minor and Major parameters, user receive a notification with deeplinking in application.


Beside this alert messages what should we do based on your code review?






-(void)sendLocationToServer:(NSString*)longa lat:(NSString*)lat{


NSString* url = [NSString stringWithFormat:@"%@/storeGps", locappyURL];

NSMutableDictionary* muParams = [[NSMutableDictionary alloc] init];

__block BOOL isDownloading = NO;

[muParams setObject:USER_ID forKey:@"user_id"];

LocationBlock* loc = [[LocationBlock alloc] initWithBlock:^(CLLocation* location){

[muParams setObject:[NSString stringWithFormat:@"%f",location.coordinate.latitude ] forKey:@"lat"];

[muParams setObject:[NSString stringWithFormat:@"%f",location.coordinate.longitude ] forKey:@"lng"];

if (!isDownloading) {

isDownloading = YES;

[self GET:url

parameters:muParams

success:^(AFHTTPRequestOperation *operation, id responseObject) {

/ /

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

/ %@", error.localizedDescription);

}];

}

}];

}


-(void)recievedNotification:(NSString *)notificationID{

NSString* url = [NSString stringWithFormat:@"%@/notificationReceived", locappyURL];

NSDictionary* params = [[NSDictionary alloc] initWithObjectsAndKeys:USER_ID,@"user_id",notificationID,@"notification_id", nil];

[self GET:url

parameters:params

success:^(AFHTTPRequestOperation *operation, id responseObject) {

/ notification recieved");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

/ %@", error.localizedDescription);

}];

}


-(void)interactedWithNotification:(NSString *)notificationID{

NSString* url = [NSString stringWithFormat:@"%@/notificationInteracted", locappyURL];

NSDictionary* params = [[NSDictionary alloc] initWithObjectsAndKeys:USER_ID,@"user_id",notificationID,@"notification_id", nil];

[self GET:url

parameters:params

success:^(AFHTTPRequestOperation *operation, id responseObject) {

/ notification recieved");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

/ error.localizedDescription);

}];

}


-(void)foundBeacon:(NSNumber *)bMajor minor:(NSNumber*)bMinor{

NSString* url = [NSString stringWithFormat:@"%@/beaconInteraction", locappyURL];

NSDictionary* params = [[NSDictionary alloc] initWithObjectsAndKeys:USER_ID,@"user_id",bMajor,@"major",bMinor,@"minor", nil];

[self GET:url

parameters:params

success:^(AFHTTPRequestOperation *operation, id responseObject) {

/ notification recieved");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

/ %@", error.localizedDescription);

}];

}



In AppDelegate there are presented all messages for this interactions that are presented in the application.


-(void)updatePushState:(NSNotification *) notification

{

/

if([[notification object] boolValue])

{

/

if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedAlways && [CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedWhenInUse) {

NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

if ([[UIApplication sharedApplication] canOpenURL:settingsURL]) {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Allow \"Locappy\" to access your location while you use the app" message:@"Locappy needs to use your current location to let you discover what's around you" delegate:self cancelButtonTitle:@"Allow" otherButtonTitles:@"Don't Allow", nil];

alert.tag=123;

[alert show];

}

else {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Allow \"Locappy\" to access your location while you use the app" message:@"Locappy needs to use your current location to let you discover what's around you" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

alert.tag=123;

[alert show];

}

}

}

else

{

NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

if ([[UIApplication sharedApplication] canOpenURL:settingsURL]) {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"\"Locappy\" Would Like to Send You Notifications" message:@"Notifications may include alerts, sounds, and icon badges. These can be configured in Settings" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];

alert.tag=123;

[alert show];

}

else {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"\"Locappy\" Would Like to Send You Notifications" message:@"Notifications may include alerts, sounds, and icon badges. These can be configured in Settings" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];

alert.tag=123;

[alert show];

}

}

}

Edit: Bah. I posted my initial answer about Bluetooth permissions in the wrong (but similar) thread about CoreLocation beacon regions. This is what I get for opening threads about two rejections relating to beacons at the same time!


Firstly, this one probably belongs in the CoreLocation forums.


But secondly, my understanding is that CoreLocation Beacons don't require persistent background location; you're not actually getting GPS coordinates in the beacon notification, just getting Beacon identifiers. And since, based on the code included above, you're only reading the location once the app is launched from the Beacon region notification (i.e., is in the foreground), this would mean you don't need persistent background location permissions at all.


Hope that helps. 🙂

Declaring features that require persistent location
 
 
Q