File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -290,12 +290,19 @@ + (void)showLocationSettingsAlertController {
290290 }];
291291}
292292
293+ + (BOOL )backgroundTaskIsActive {
294+ return fcTask && (fcTask != UIBackgroundTaskInvalid);
295+ }
296+
293297+ (void )requestLocation {
294298 onesignal_Log (ONE_S_LL_DEBUG, @" OneSignalLocation Requesting Updated Location" );
295299 id clLocationManagerClass = NSClassFromString (@" CLLocationManager" );
296300 if ([UIApplication sharedApplication ].applicationState == UIApplicationStateBackground
297301 && [clLocationManagerClass performSelector: @selector (significantLocationChangeMonitoringAvailable )]) {
298302 [locationManager performSelector: @selector (startMonitoringSignificantLocationChanges )];
303+ if ([self backgroundTaskIsActive ]) {
304+ [self endTask ];
305+ }
299306 } else {
300307 [locationManager performSelector: @selector (requestLocation )];
301308 }
@@ -345,11 +352,17 @@ - (void)locationManager:(id)manager didUpdateLocations:(NSArray *)locations {
345352 [OneSignalLocation sendLocation ];
346353
347354 [OneSignalLocation sendAndClearLocationListener: PERMISSION_GRANTED];
355+ if ([OneSignalLocation backgroundTaskIsActive ]) {
356+ [OneSignalLocation endTask ];
357+ }
348358}
349359
350360- (void )locationManager : (id )manager didFailWithError : (NSError *)error {
351361 [OneSignal onesignal_Log: ONE_S_LL_ERROR message: [NSString stringWithFormat: @" CLLocationManager did fail with error: %@ " , error]];
352362 [OneSignalLocation sendAndClearLocationListener: ERROR];
363+ if ([OneSignalLocation backgroundTaskIsActive ]) {
364+ [OneSignalLocation endTask ];
365+ }
353366}
354367
355368+ (void )resetSendTimer {
You can’t perform that action at this time.
0 commit comments