25
25
26
26
@implementation RCTBackgroundGeolocation {
27
27
MAURBackgroundGeolocationFacade* facade;
28
+
29
+ API_AVAILABLE (ios (10.0 ))
30
+ __weak id <UNUserNotificationCenterDelegate > prevNotificationDelegate;
28
31
}
29
32
30
33
@synthesize bridge = _bridge;
@@ -375,16 +378,21 @@ -(void) onAppPause:(NSNotification *)notification
375
378
*/
376
379
-(void ) onFinishLaunching : (NSNotification *)notification
377
380
{
378
- if (@available (iOS 10 , *)) {
379
- UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter ];
380
- center.delegate = self;
381
- }
382
-
383
381
NSDictionary *dict = [notification userInfo ];
384
382
383
+ MAURConfig *config = [facade getConfig ];
384
+ if (config.isDebugging )
385
+ {
386
+ if (@available (iOS 10 , *))
387
+ {
388
+ UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter ];
389
+ prevNotificationDelegate = center.delegate ;
390
+ center.delegate = self;
391
+ }
392
+ }
393
+
385
394
if ([dict objectForKey: UIApplicationLaunchOptionsLocationKey]) {
386
395
RCTLogInfo (@" RCTBackgroundGeolocation started by system on location event." );
387
- MAURConfig *config = [facade getConfig ];
388
396
if (![config stopOnTerminate ]) {
389
397
[facade start: nil ];
390
398
[facade switchMode: MAURBackgroundMode];
@@ -396,7 +404,18 @@ -(void) userNotificationCenter:(UNUserNotificationCenter *)center
396
404
willPresentNotification : (UNNotification *)notification
397
405
withCompletionHandler : (void (^)(UNNotificationPresentationOptions options))completionHandler
398
406
{
399
- completionHandler (UNNotificationPresentationOptionAlert );
407
+ if (prevNotificationDelegate && [prevNotificationDelegate respondsToSelector: @selector (userNotificationCenter:willPresentNotification:withCompletionHandler: )])
408
+ {
409
+ // Give other delegates (like FCM) the chance to process this notification
410
+
411
+ [prevNotificationDelegate userNotificationCenter: center willPresentNotification: notification withCompletionHandler: ^(UNNotificationPresentationOptions options) {
412
+ completionHandler (UNNotificationPresentationOptionAlert );
413
+ }];
414
+ }
415
+ else
416
+ {
417
+ completionHandler (UNNotificationPresentationOptionAlert );
418
+ }
400
419
}
401
420
402
421
-(void ) onAppTerminate : (NSNotification *)notification
0 commit comments