Commit a42abe87 authored by Chris Scott's avatar Chris Scott

Upgrade plugin for new ios 8 permission request of background geolocation. ...

Upgrade plugin for new ios 8 permission request of background geolocation.  also asked for permissions to display local-notifications when in debug mode
parent f6a27869
...@@ -52,6 +52,11 @@ ...@@ -52,6 +52,11 @@
<platform name="ios"> <platform name="ios">
<!-- required background modes: App registers for location updates --> <!-- required background modes: App registers for location updates -->
<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
<string>This app requires background location tracking</string>
</config-file>
<config-file target="*-Info.plist" parent="UIBackgroundModes"> <config-file target="*-Info.plist" parent="UIBackgroundModes">
<array> <array>
<string>location</string> <string>location</string>
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSuspend:) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSuspend:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume:) name:UIApplicationWillEnterForegroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume:) name:UIApplicationWillEnterForegroundNotification object:nil];
} }
/** /**
* configure plugin * configure plugin
...@@ -133,6 +134,14 @@ ...@@ -133,6 +134,14 @@
NSLog(@" - activityType: %@", [command.arguments objectAtIndex:7]); NSLog(@" - activityType: %@", [command.arguments objectAtIndex:7]);
NSLog(@" - debug: %d", isDebugging); NSLog(@" - debug: %d", isDebugging);
NSLog(@" - stopOnTerminate: %d", stopOnTerminate); NSLog(@" - stopOnTerminate: %d", stopOnTerminate);
// ios 8 requires permissions to send local-notifications
if (isDebugging) {
UIApplication *app = [UIApplication sharedApplication];
if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[app registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
}
} }
- (void) addStationaryRegionListener:(CDVInvokedUrlCommand*)command - (void) addStationaryRegionListener:(CDVInvokedUrlCommand*)command
...@@ -557,7 +566,7 @@ ...@@ -557,7 +566,7 @@
- (void) fireStationaryRegionListeners:(NSMutableDictionary*)data - (void) fireStationaryRegionListeners:(NSMutableDictionary*)data
{ {
NSLog(@"- CDVBackgroundGeoLocation#fireStationaryRegionListeners: %d", [locationQueue count]); NSLog(@"- CDVBackgroundGeoLocation#fireStationaryRegionListener");
if (![self.stationaryRegionListeners count]) { if (![self.stationaryRegionListeners count]) {
[self stopBackgroundTask]; [self stopBackgroundTask];
return; return;
...@@ -701,8 +710,15 @@ ...@@ -701,8 +710,15 @@
- (void) startUpdatingLocation - (void) startUpdatingLocation
{ {
SEL requestSelector = NSSelectorFromString(@"requestWhenInUseAuthorization");
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined && [locationManager respondsToSelector:requestSelector]) {
((void (*)(id, SEL))[locationManager methodForSelector:requestSelector])(locationManager, requestSelector);
[locationManager startUpdatingLocation]; [locationManager startUpdatingLocation];
isUpdatingLocation = YES; isUpdatingLocation = YES;
} else {
[locationManager startUpdatingLocation];
isUpdatingLocation = YES;
}
} }
- (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status - (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment