Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onMessageReceived doesn't get triggered after cold start #917

Open
4 of 5 tasks
nivlempert1 opened this issue Dec 4, 2024 · 10 comments
Open
4 of 5 tasks

onMessageReceived doesn't get triggered after cold start #917

nivlempert1 opened this issue Dec 4, 2024 · 10 comments

Comments

@nivlempert1
Copy link

nivlempert1 commented Dec 4, 2024

Bug report

CHECKLIST

  • I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
  • I have checked that no similar issues (open or closed) already exist.

Current behavior:

happens on iOS-
Quit the app
Send a notification
Press on the notification to open the app
onMessageReceived doesn't trigger- so the notification data is lost

I've read the documentation regarding the changes and I still can't make that case work. I tried both true and false for FIREBASE_MESSAGING_IMMEDIATE_PAYLOAD_DELIVERY

Tried both versions 17.0.0 and 18.0.0, it worked well on 17.0.0, and didn't on 18.0.0. I saw a lot of changes regarding notifications in 18.0.0

Expected behavior:

Quit the app
Send a notification
Press on the notification to open the app
onMessageReceived should trigger and then I can use the notification's data to further direct the user.

Environment information

  • Cordova CLI version - 12.0.0

  • Cordova platform version - 7.1.1

  • Plugins & versions installed in project (including this plugin)
    @moodlehq/cordova-plugin-local-notification 0.9.0-moodle.12 "LocalNotification"
    com.darktalker.cordova.screenshot 0.1.5 "Screenshot"
    cordova-clipboard 1.3.0 "Clipboard"
    cordova-launch-review 4.1.1 "Launch Review"
    cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
    cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
    cordova-plugin-app-version 0.1.14 "AppVersion"
    cordova-plugin-badge 0.8.9 "Badge"
    cordova-plugin-deeplinks 1.1.1 "Cordova Deeplinks Plugin"
    cordova-plugin-device 2.1.0 "Device"
    cordova-plugin-file-transfer 2.0.1-dev "File Transfer"
    cordova-plugin-file 8.1.3 "File"
    cordova-plugin-firebasex 17.0.0 "Google Firebase Plugin"
    cordova-plugin-fullscreen 1.3.0 "cordova-plugin-fullscreen"
    cordova-plugin-inappbrowser 6.0.0 "InAppBrowser"
    cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
    cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
    cordova-plugin-localization-strings 5.0.5 "Localization"
    cordova-plugin-navigationbar-color 0.0.8 "NavigationBar"
    cordova-plugin-purchase 13.11.1 "Purchase"
    cordova-plugin-statusbar 4.0.0 "StatusBar"
    cordova-plugin-tts-advanced 0.5.2 "TTS"
    cordova-plugin-x-socialsharing 6.0.4 "SocialSharing"
    cordova-promise-polyfill 0.0.2 "cordova-promise-polyfill"
    cordova-sqlite-storage 6.1.0 "Cordova SQLite storage plugin - cordova-sqlite-storage plugin version"
    es6-promise-plugin 4.2.2 "Promise"

  • Dev machine OS and version, e.g.

    • OSX- 15.1.1

Runtime issue

  • Device details - iPhone 16 Pro Simulator- iOS 18.1
@Wallethub
Copy link

Wallethub commented Jan 11, 2025

I can confirm we are seeing the same thing after updating to the latest. iOS only. Both in Simulator and actual device

@intellectsatheeshkumar
Copy link

@dpa99c I'm also facing same issue on ios devices

@pitAlex
Copy link

pitAlex commented Jan 17, 2025

I can see it also @dpa99c it looks like the issue came with the introduction of the code regarding not delivering the push payload immediately.

@dpa99c
Copy link
Owner

dpa99c commented Jan 17, 2025

Looks like the merge of PR #902 introduced this bug.
@ochakov any idea what changes in your PR might have caused this and how to fix it without backing out your changes?

@ochakov
Copy link

ochakov commented Jan 17, 2025

@nivlempert1 Do you see the issue only when starting the app by clicking the notification icon? What if you normally start the app? onMessageReceived should trigger the moment you call it.

@pitAlex
Copy link

pitAlex commented Jan 17, 2025

@nivlempert1 Do you see the issue only when starting the app by clicking the notification icon? What if you normally start the app? onMessageReceived should trigger the moment you call it.

I see it when starting the app by tapping on the push notification.

@ochakov
Copy link

ochakov commented Jan 20, 2025

I was unable to replicate the problem. All pending notifications are being sent to the onMessageReceived callback once the app has been started.

@pitAlex
Copy link

pitAlex commented Jan 28, 2025

I was unable to replicate the problem. All pending notifications are being sent to the onMessageReceived callback once the app has been started.

@ochakov are you checking onMessageReceived of the WebView? I have a video here where I am registering a callback right when the device is ready and it is not firing. I am noticing that the log printed by the plugin regarding didReceiveNotificationResponse is showing up, the the console log from my callback is not (I have FIREBASE_MESSAGING_IMMEDIATE_PAYLOAD_DELIVERY set to false):
https://drive.google.com/file/d/1LYgl947sen6weKoLTfpelM7-uZBpLSFj/view?usp=sharing

@pitAlex
Copy link

pitAlex commented Feb 5, 2025

I've managed to fix this by adding

self.notificationCallbackId != nil

as part of the condition in the method

- (void)sendPendingNotifications

Also, not sure why are you call this one twice on

- (void)applicationDidBecomeActive:(UIApplication *)application

once inside the "try" block and then again outside it.

@nivlempert1
Copy link
Author

@pitAlex If you believe your solution is appropriate, I’d appreciate it if you could share it with us in a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants