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.

bug: PushNotifications on Android, if the app is killed will not show

See original GitHub issue

Bug Report

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/cli 2.4.0
  @capacitor/core 2.4.0
  @capacitor/android 2.4.0
  @capacitor/ios 2.4.0
  @capacitor/electron not installed

Platform(s)

  • Android 10

Current Behavior

The push notifications (setup via tutorial) and send via firebase console do not work if the application is closed (not minimized) on the phone.

Expected Behavior

The sent push notifications should be in the system tray.

Code Reproduction

Other Technical Details

npm --version output: 6.12.1

node --version output: v12.13.1

pod --version output (iOS issues only): –

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:14

github_iconTop GitHub Comments

6reactions
bolivircommented, Oct 17, 2020

Ok, it seems that the phonegap push plugin had a custom implementation for handling data only pushes. Then it makes sense for me too see this behaviour when sending the payload as i described above.

So for anyone with the described problem verify that youre not sending data only pushes as they wont trigger the notification when the app is closed or in the background.

I think some better documentation on the capacitor site would prevend users for this … huh moment. Some payloads examples would help and as a side note notice that data only pushes dont trigger the notification when the app is closed or in the background.

5reactions
Avaretocommented, Oct 18, 2020

receiving message in the background and when the app was close on Android works with capacitor push plugin ony if you send the following firebase cloud message payload:

{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "title":"Portugal vs. Denmark",
      "body":"great match!"
    },
    "data" : {
      "Nick" : "Mario",
      "Room" : "PortugalVSDenmark"
    }
}

See here: https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Notifications Not Showing Up? 10 Fixes You Can Try
Not seeing notifications show up on your Android phone? Try these fixes to get Android notifications working again.
Read more >
android - Push not received when app is killed - Stack Overflow
I've noticed that I get different behaviour depending on how the app was launched before I swiped it closed, as bizarre as that...
Read more >
Android device cannot receive push notifications when an ...
Android device cannot receive push notifications when an application is force stopped ("killed") · Go to Settings > Apps & Notifications > enable...
Read more >
Notifications Not Shown - Mobile Push
Common reasons why Mobile Push notifications are not showing on your device. ... When an app is in a Force Stopped / Force...
Read more >
Push Notifications Capacitor Plugin API
Android ​. This plugin does support data-only notifications, but will NOT call pushNotificationReceived if the app has been killed. To handle this scenario, ......
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