andrehtissot / cordova-plugin-fcm-with-dependecy-updated

Google FCM Push Notifications Cordova Plugin
MIT License
209 stars 278 forks source link

onNotification is not trigger when app is background #173

Open gushi0224 opened 4 years ago

gushi0224 commented 4 years ago

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"
  },
andrehtissot commented 4 years ago

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):

m-alcu commented 4 years ago

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

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

marcosjara commented 4 years ago

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

m-alcu commented 4 years ago

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 notifications@github.com 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 .

andrehtissot commented 4 years ago

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

najmulansari commented 4 years ago

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

camengadisaputra-dev commented 4 years ago

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

iChristosK commented 3 years ago

Having the same issue

nabilsadki commented 3 years ago

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.

andrehtissot commented 3 years ago

@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().