Skip to content

Commit 97219a1

Browse files
author
Joseph Kalash
authored
Merge pull request #70 from jrtapiaO/develop
Crash fix - ios8 - CLLocationManager.allowsBackgroundLocationUpdates
2 parents 60ff363 + 5687aa7 commit 97219a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

iOS_SDK/OneSignal/OneSignalLocation.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ + (void) internalGetLocation:(bool)prompt {
160160
locationManager = [[clLocationManagerClass alloc] init];
161161
[locationManager setValue:[self sharedInstance] forKey:@"delegate"];
162162

163-
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
163+
float deviceOSVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
164+
if (deviceOSVersion >= 8.0) {
164165

165166
//Check info plist for request descriptions
166167
//LocationAlways > LocationWhenInUse > No entry (Log error)
@@ -169,7 +170,9 @@ + (void) internalGetLocation:(bool)prompt {
169170
NSString* alwaysDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"];
170171
if(backgroundModes && [backgroundModes containsObject:@"location"] && alwaysDescription) {
171172
[locationManager performSelector:@selector(requestAlwaysAuthorization)];
172-
[locationManager setValue:@YES forKey:@"allowsBackgroundLocationUpdates"];
173+
if (deviceOSVersion >= 9.0) {
174+
[locationManager setValue:@YES forKey:@"allowsBackgroundLocationUpdates"];
175+
}
173176
}
174177

175178
else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"])

0 commit comments

Comments
 (0)