chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging
MIT License
164 stars 160 forks source link

IONIC v3 android app does not receive FCM notification message sent from Node.js applciation SDK firebase-admin #176

Closed haresh333 closed 3 years ago

haresh333 commented 3 years ago

Problem - Recipient client app does not receive PUSH notification when sent from my server app I have IONIC v3 mobile app and using @ionic-native/firebase-messaging@4.20.0, cordova-plugin-firebase-messaging@2.1.6 I also have PWA app built from same codebase

Observations

  1. When I send message from server to IONIC app, it does not receive - neither in foreground nor background mode
  2. When I send message from same server to IONIC PWA app, PWA app receives message.

The server code admin.messaging().send(payload) returns success response with following projects//messages/0:1610460192971479%9edb2772f9fd7ecd

With this I infer in all likelihood there is no issue with Server code

Using debugging, I capture token of the IONIC mobile app getToken().

  1. When I send Google Firebase Console to this token if the app is in foreground I do not get the message. 4.When I send Google Firebase Console to this token if the app is in background I DO GET the message. I see this in notification drawer in Mobile. However, I dont think the App get the message (no console message in the console.)

What may be wrong, How do I investigate?

I am using Following application stack

Server (to send FCM push messages) Node v10.22.0 "firebase-admin": "^8.12.1",

Client (To receive message) Android Device is using Android 6.0 OS IONIC v3.9 "@angular/core": "5.2.11", "cordova": "^9.0.0", "cordova-android": "7.1.1", "@ionic-native/firebase-messaging": "^4.20.0", "cordova-plugin-firebase-messaging": "2.1.6",

Android SDK Tools : 26.1.1
Node              : v14.15.3

@ionic/app-scripts : 3.2.4
Cordova Platforms  : android 7.1.1
Ionic Framework    : ionic-angular 3.9.2
haresh333 commented 3 years ago

Some Updates.. when I view adb logcat I see below activity with respect to my application package.

01-15 17:12:48.489 940 2000 V ActivityManager: Broadcast: Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.PeRuPe.services (has extras) } ordered=true userid=0 callerApp=ProcessRecord{593c4a4 1730:com.google.android.gms.persistent/u0a12} 01-15 17:12:48.490 940 1007 V ActivityManager_MU: isSingleton(com.PeRuPe.services, ApplicationInfo{faceff3 com.PeRuPe.services}, com.google.firebase.iid.FirebaseInstanceIdReceiver, 0x0) = false 01-15 17:12:48.493 2030 2030 D ActivityThread: BDC-Calling onReceive: intent=Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.PeRuPe.services cmp=com.PeRuPe.services/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }, receiver=com.google.firebase.iid.FirebaseInstanceIdReceiver@fffdf6a 01-15 17:12:48.495 940 965 V ActivityManager_MU: bringUpServiceLocked: appInfo.uid=10787 app=ProcessRecord{d5168b2 2030:com.PeRuPe.services/u0a787} 01-15 17:12:48.500 940 2005 D PowerManagerService: acquireWakeLockInternal: lock=187539025, flags=0x1, tag="androidx.core:wake:com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService", ws=null, uid=10787, pid=2030 01-15 17:12:48.500 940 2005 D PowerManagerNotifier: onWakeLockAcquired: flags=1, tag="androidx.core:wake:com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService", packageName=com.PeRuPe.services, ownerUid=10787, ownerPid=2030, workSource=null 01-15 17:12:48.500 940 2005 D AppOps : startOperation: allowing code 40 uid 10787 package com.PeRuPe.services 01-15 17:12:48.501 2030 2030 D ActivityThread: BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.PeRuPe.services (has extras) } packageName=com.PeRuPe.services resultCode=-1 resultData=null resultExtras=null} 01-15 17:12:48.502 2030 2030 D ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@c009c5b className=by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService packageName=com.PeRuPe.services intent=null} 01-15 17:12:48.502 940 2001 D PowerManagerNotifier: onWakeLockReleased: flags=1, tag="GOOGLE_C2DM", packageName=com.google.android.gms, ownerUid=10012, ownerPid=1730, workSource=WorkSource{10787 com.PeRuPe.services} 01-15 17:12:48.504 2030 2030 D ActivityThread: SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@c009c5b className=by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService packageName=com.PeRuPe.services intent=null} 01-15 17:12:48.504 2030 2030 D ActivityThread: SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@c009c5b startId=1 args=Intent { act=com.google.firebase.MESSAGING_EVENT pkg=com.PeRuPe.services cmp=com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService (has extras) }} 01-15 17:12:48.516 940 965 D PowerManagerService: releaseWakeLockInternal: lock=187539025 [androidx.core:wake:com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService], flags=0x0, total_time=16ms 01-15 17:12:48.516 940 965 D PowerManagerNotifier: onWakeLockReleased: flags=1, tag="androidx.core:wake:com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService", packageName=com.PeRuPe.services, ownerUid=10787, ownerPid=2030, workSource=null 01-15 17:12:48.517 940 1512 V ActivityManager_MU: getServiceByName(ComponentInfo{com.PeRuPe.services/by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService}), callingUser = 0

What can be meaning of this, is the application not able to catch hold of PUSH ?

chemerisuk commented 3 years ago

@haresh333 by default when app is in foreground only onMessage callback triggered without native notifications. If you need native notifications pass forceShow option into requestPermission call.