cordova-plugin-fcm-with-dependecy-updated icon indicating copy to clipboard operation
cordova-plugin-fcm-with-dependecy-updated copied to clipboard

onNotification is not trigger when app is background

Open gushi0224 opened this issue 4 years ago • 10 comments

Describe the bug When app is background or killed, app cann't receive push message.

Package.json

"dependencies": {
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/compiler-cli": "5.0.0",
    "@angular/core": "5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@auth0/angular-jwt": "^1.2.0",
    "@ionic-native-mocks/app-version": "^2.0.12",
    "@ionic-native/app-availability": "^4.20.0",
    "@ionic-native/app-version": "^4.20.0",
    "@ionic-native/background-mode": "^4.7.0",
    "@ionic-native/call-number": "^4.20.0",
    "@ionic-native/camera": "^4.7.0",
    "@ionic-native/code-push": "^4.20.0",
    "@ionic-native/core": "^4.18.0",
    "@ionic-native/device": "^4.6.0",
    "@ionic-native/document-viewer": "^4.7.0",
    "@ionic-native/file": "^4.20.0",
    "@ionic-native/file-opener": "^4.7.0",
    "@ionic-native/file-transfer": "^4.7.0",
    "@ionic-native/fingerprint-aio": "^4.20.0",
    "@ionic-native/geolocation": "^4.14.0",
    "@ionic-native/globalization": "^4.20.0",
    "@ionic-native/http": "^4.20.0",
    "@ionic-native/in-app-browser": "^4.20.0",
    "@ionic-native/launch-navigator": "^4.18.0",
    "@ionic-native/local-notifications": "^4.20.0",
    "@ionic-native/native-audio": "^4.7.0",
    "@ionic-native/network": "^4.20.0",
    "@ionic-native/phonegap-local-notification": "^4.7.0",
    "@ionic-native/qr-scanner": "^4.20.0",
    "@ionic-native/screen-orientation": "^4.7.0",
    "@ionic-native/secure-storage": "^4.20.0",
    "@ionic-native/sim": "^4.9.0",
    "@ionic-native/sms": "^4.7.0",
    "@ionic-native/spinner-dialog": "^4.20.0",
    "@ionic-native/splash-screen": "^4.20.0",
    "@ionic-native/sqlite": "~4.6.0",
    "@ionic-native/status-bar": "^4.3.1",
    "@ionic-native/streaming-media": "^4.20.0",
    "@ionic-native/themeable-browser": "^4.20.0",
    "@ionic-native/toast": "^4.20.0",
    "@ionic-native/unique-device-id": "^4.20.0",
    "@ionic-native/vibration": "^4.7.0",
    "@ionic-native/web-intent": "^4.20.0",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "^9.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "angular2-signaturepad": "^2.8.0",
    "call-number": "file:local_plugin/mx.ferreyra.callnumber",
    "code-push": "^3.0.1",
    "com-darryncampbell-cordova-plugin-intent": "file:local_plugin/com-darryncampbell-cordova-plugin-intent",
    "com-plugin-homepanic": "file:local_plugin/com-plugin-homepanic",
    "com-plugin-systemvolume": "file:local_plugin/com-plugin-systemvolume",
    "cordova-android": "8.1.0",
    "cordova-browser": "^6.0.0",
    "cordova-ios": "^5.1.1",
    "cordova-phone-call-trap": "file:local_plugin/cordova-phone-call-trap",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-advanced-http": "^3.0.0",
    "cordova-plugin-android-fingerprint-auth": "^1.5.0",
    "cordova-plugin-androidx": "^2.0.0",
    "cordova-plugin-androidx-adapter": "1.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-appavailability": "^0.4.2",
    "cordova-plugin-background-mode": "file:local_plugin/cordova-plugin-background-mode",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-camera": "file:local_plugin/cordova-plugin-camera",
    "cordova-plugin-code-push": "^1.12.5",
    "cordova-plugin-decimal-keyboard": "git+https://github.com/mrchandoo/cordova-plugin-decimal-keyboard.git",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-document-viewer": "^0.9.13",
    "cordova-plugin-fcm-with-dependecy-updated": "file:local_plugin/cordova-plugin-fcm-with-dependecy-updated",
    "cordova-plugin-file": "file:local_plugin/cordova-plugin-file",
    "cordova-plugin-file-opener2": "^2.2.1",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-fingerprint-aio": "^3.0.1",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-globalization": "^1.11.0",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.2.1",
    "cordova-plugin-jcore": "^1.3.3",
    "cordova-plugin-local-notification": "git+https://github.com/Steffaan/cordova-plugin-local-notifications.git",
    "cordova-plugin-native-spinner": "^1.1.3",
    "cordova-plugin-nativeaudio": "file:local_plugin/cordova-plugin-nativeaudio",
    "cordova-plugin-nativegeolocation": "file:local_plugin/cordova-plugin-nativegeolocation",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-qrscanner": "file:local_plugin/cordova-plugin-qrscanner",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-secure-storage": "git+https://github.com/OutSystems/cordova-plugin-secure-storage.git#2.6.8-OS1",
    "cordova-plugin-sim": "^1.3.3",
    "cordova-plugin-splashscreen": "^5.0.4",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-streaming-media": "^2.2.0",
    "cordova-plugin-themeablebrowser": "file:local_plugin/cordova-plugin-themeablebrowser",
    "cordova-plugin-uniquedeviceid": "file:local_plugin/cordova-plugin-uniquedeviceid",
    "cordova-plugin-vibration": "^3.1.1",
    "cordova-plugin-whitelist": "^1.3.4",
    "cordova-plugin-x-toast": "^2.7.2",
    "cordova-plugin-zip": "^3.1.0",
    "cordova-sms-plugin": "^0.1.13",
    "cordova-sqlite-storage": "~2.6.0",
    "es6-promise-plugin": "^4.2.2",
    "ionic-angular": "3.9.2",
    "ionic3-jpush": "^1.2.0",
    "ionicons": "3.0.0",
    "jpush-phonegap-plugin": "file:local_plugin/jpush-phonegap-plugin",
    "jstz": "^2.0.0",
    "jszip": "~3.2.2",
    "moment": "^2.24.0",
    "pako": "^1.0.10",
    "pdfjs-dist": "2.0.943",
    "phonegap-plugin-local-notification": "^1.0.1",
    "rxjs": "~5.5.2",
    "signature_pad": "^2.3.2",
    "soap": "^0.33.0",
    "sw-toolbox": "3.6.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.2.2",
    "zone.js": "0.8.18"
  },

gushi0224 avatar Sep 14 '20 03:09 gushi0224

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Developer OS and version: [e.g. MacOS Mojave]
  • Mobile OS and version: [e.g. iOS 13.0.1]
  • Cordova CLI version (cordova --version): [e.g. 9.0.0 ]
  • Cocoapods version (pod --version): [e.g. 9.0.0]
  • Xcode version (xcodebuild -version): [e.g. 11.1.0]

andrehtissot avatar Sep 16 '20 16:09 andrehtissot

Perhaps did you miss to put "click_action"....,

"notification" : { "body" : "el body", "title": "title", "click_action": "FCM_PLUGIN_ACTIVITY" },

m-alcu avatar Sep 25 '20 16:09 m-alcu

Hello m-alcu

I have the same problem, issuing fcm notifications from a nodejs server using the firebase-admin 9.1.0 library

In your answer you mention that the click_action was missing,

I have seen that it is a requirement to send notifications to Android, but how do I do if what I want is to send only a message and not a notification

How could I put the click_action in the body of the payload, when I only send a ['data']

If I try to place the click_action at the root of the payload I get an error that only 'notification' and 'data' are valid for the body of the message

Thank you

marcosjara avatar Sep 26 '20 03:09 marcosjara

I doubt that this is possible with this plugin. The message is inside Notification that launches activity and passes data to pluggin.

On Sat, 26 Sep 2020 at 05:28, marcosjara [email protected] wrote:

Hello m-alcu

I have the same problem, issuing fcm notifications from a nodejs server using the firebase-admin 9.1.0 library

In your answer you mention that the click_action was missing,

I have seen that it is a requirement to send notifications to Android, but how do I do if what I want is to send only a message and not a notification

How could I put the click_action in the body of the payload, when I only send a ['data']

If I try to place the click_action at the root of the payload I get an error that only 'notification' and 'data' are valid for the body of the message

Thank you

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues/173#issuecomment-699303453, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFYGYBWYRLBYFFL6ANOZDTSHVNWDANCNFSM4RLCHUEQ .

m-alcu avatar Sep 26 '20 06:09 m-alcu

Unfortunately, there is no consistent way to have a data-only message working without writing the service in java yourself.

andrehtissot avatar Sep 28 '20 17:09 andrehtissot

Hi All, I am in the same situation. notification works when the app is in the foreground and in the background, but it does not work when my Android app is closed. When the app is closed, I do get a notification message and on tap, it also opens the app but the tap event in the code does not get fired. Please help If you have any clue.

Thanks

najmulansari avatar Oct 19 '20 20:10 najmulansari

Hello m-alcu

I have the same problem, issuing fcm notifications from a nodejs server using the firebase-admin 9.1.0 library

In your answer you mention that the click_action was missing,

I have seen that it is a requirement to send notifications to Android, but how do I do if what I want is to send only a message and not a notification

How could I put the click_action in the body of the payload, when I only send a ['data']

If I try to place the click_action at the root of the payload I get an error that only 'notification' and 'data' are valid for the body of the message

Thank you

you need to use sendToDevice instead send https://firebase.google.com/docs/cloud-messaging/send-message#defining-the-message-options

camengadisaputra-dev avatar Oct 20 '20 08:10 camengadisaputra-dev

Having the same issue

iChristosK avatar Nov 11 '20 09:11 iChristosK

Hi I have the same issue :( , if the app is closed, and i tap the notification, when the app is launched, the onNotification is not fired.

nabilsadki avatar Jan 01 '21 22:01 nabilsadki

@nabilsadki If the notification is received before the onNotification is executed, i.e. on app start, then the event is triggered before there is any listener. If you want to get access to the notification that opens the app, please use getInitialPushPayload().

andrehtissot avatar Feb 03 '21 21:02 andrehtissot