question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plugin doesn't let cordova-plugin-fcm-with-dependecy-updated ^2.4.0 plugin handle notification

See original GitHub issue

Your Environment

  • Plugin version: 3.0.3
  • Platform: iOS
  • OS version: 11.0.3 and 12.3.1
  • Device manufacturer and model: iPhone 6, iPhone 6s
  • Running in Simulator: no
  • Cordova version (cordova -v): 8.1.2
  • Cordova platform version (cordova platform ls): ios 4.5.4
  • Plugin configuration options:
geolocation.configure({
            locationProvider: _geolocation.ACTIVITY_PROVIDER,
            desiredAccuracy: _geolocation.MEDIUM_ACCURACY,
            stationaryRadius: 0,
            distanceFilter: 0,
            debug: false,
            stopOnTerminate: true,
            stopOnStillActivity: false,
            startForeground: true,
            fastestInterval: 10000,
            interval: 10000,
            maxLocations: 1
        }
  • Link to your project:

Context

in CDVBackgroundGeolocation.m file debugger never goes into if statement

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
    if (prevNotificationDelegate && [prevNotificationDelegate respondsToSelector:@selector(userNotificationCenter:willPresentNotification:withCompletionHandler:)])
    {
        // Give other delegates (like FCM) the chance to process this notification

        [prevNotificationDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:^(UNNotificationPresentationOptions options) {
            completionHandler(UNNotificationPresentationOptionAlert);
        }];
    }
    else
    {
        completionHandler(UNNotificationPresentationOptionAlert);
    }
}

Expected Behavior

plugin should let others handle push data (in my case fcm, which works properly without this plugin)

Actual Behavior

debugger always choses else statement and only displays notification in upper banner, no matter if app is foreground

Steps to Reproduce

  1. clear project
  2. cordova plugin add cordova-plugin-fcm-with-dependecy-updated@^2.4.0
  3. cordova plugin add @mauron85/cordova-plugin-background-geolocation@3.0.3
  4. put breakpoint on line 484 in CDVBackgroundGeolocation.m
  5. send any test push from firebase console

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
walfridospcommented, Jan 21, 2020

@ProximaHaiz just in case you haven’t fix this issue yet, I solved it from my side by commenting these lines in plugins/cordova-plugin-mauron85-background-geolocation/CDVBackgroundGeolocation.m

    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppPause:) name:UIApplicationDidEnterBackgroundNotification object:nil];
    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppResume:) name:UIApplicationWillEnterForegroundNotification object:nil];
    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil];
    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate:) name:UIApplicationWillTerminateNotification object:nil];

After that Push Notifications worked as expected.

Hope this helps.

2reactions
ynunezcommented, May 7, 2020

@nuno @ProximaHaiz @walfridosp @dzziwny @mauron85 I have a PR that fixes the issue https://github.com/mauron85/cordova-plugin-background-geolocation/pull/696

The problem is that it’s overriding the notification center delegate. It should only override it when it is in debugging mode. There is no need to comment out the addObserver lines

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google FCM Push Notifications Cordova Plugin - GitHub
Google Firebase Cloud Messaging Cordova Push Plugin. Extremely easy plug&play push notification plugin for Cordova applications with Google Firebase FCM.
Read more >
onNotification handler cordova-fcm-plugin-with-dependecy ...
I have implemented push notifications using the cordova-fcm-plugin-with-dependecy-updated package in my vue-cordova app.
Read more >
Blog - Apache Cordova
With the new support, the plugin will be preloaded and runs in a separate context from the web app. This feature is known...
Read more >
cordova-plugin-fcm-with-dependecy-updated@7.0.8
This does not include vulnerabilities belonging to this package's dependencies. Does your project rely on vulnerable package dependencies? Automatically find ...
Read more >
Ionic 5, FCM plugin does not request permissions to receive ...
My iPhone (a real device) does not ask for permissions to receive push notifications on Ionic 5, cordova-plugin-fcm-with-dependecy-updated ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found