Open campagna91 opened 2 years ago
Same here. Not found a solution yet.
Same with version 3.0.0
Same here
What I experienced is that there was a conflicting plugin that also dealt with push notifications. After removing the other plugin, it started working. The reason for this was that they both seemed to implement an iOS class and thus conflicted with each other. So maybe that'll help: try removing any other plugin that does something with push notifications...
I use https://www.npmjs.com/package/firebase-admin for sending push notifications thru FCM.
If I send notification in this structure, on('notification')
is not triggered:
{
"data": {
"redirectUrl": "..."
},
"notification": {
"title": "Hello by Node.js!",
"body": "It's working!"
},
"token": "{{token}}"
}
If I send this notification, on('notification')
is triggered:
{
"data": {
"redirectUrl": "...",
"title": "Hello by Node.js!",
"body": "It's working!"
},
"token": "{{token}}"
}
I call messaging.send()
method: https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsend.
I would like to try also method messaging.sendToDevice()
https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendtodevice
I use https://www.npmjs.com/package/firebase-admin for sending push notifications thru FCM.
If I send notification in this structure,
on('notification')
is not triggered:{ "data": { "redirectUrl": "..." }, "notification": { "title": "Hello by Node.js!", "body": "It's working!" }, "token": "{{token}}" }
If I send this notification,
on('notification')
is triggered:{ "data": { "redirectUrl": "...", "title": "Hello by Node.js!", "body": "It's working!" }, "token": "{{token}}" }
I call
messaging.send()
method: https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsend.I would like to try also method
messaging.sendToDevice()
https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendtodevice
Isn't it what https://github.com/havesource/cordova-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads tells you to do? I've had to use different messages for iOS and Android.
I use https://www.npmjs.com/package/firebase-admin for sending push notifications thru FCM.
If I send notification in this structure,
on('notification')
is not triggered:{ "data": { "redirectUrl": "..." }, "notification": { "title": "Hello by Node.js!", "body": "It's working!" }, "token": "{{token}}" }
If I send this notification,
on('notification')
is triggered:{ "data": { "redirectUrl": "...", "title": "Hello by Node.js!", "body": "It's working!" }, "token": "{{token}}" }
I call
messaging.send()
method: https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsend.I would like to try also method
messaging.sendToDevice()
https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendtodevice
Works like a charm! Thanks so much bro
Bug Report
Hi. After having performed a first-round with the app, if we receive a notification with the app in both state background or foreground, the 'on notification' function is called as expected.
The problem occurred if the user close the app: in this case, the function listener specified for the 'on notification' event is not triggered
Expected Behaviour
When the user taps on the notification opening the app, the .on('notification', ... function is triggered.
Actual Behaviour
The app is opened normally
Reproduce Scenario (including but not limited to)
Steps to Reproduce
Register FCM token with its callback function, close the app, receive a push and finally tap on the push received.
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android version 11 with plugin version@2.0.0
(Android) Device Vendor (e.g. Samsung, HTC, Sony...)
We tried to ore than one device, like Google Pixel 5, Samsung A series
cordova info
Printoutour cofig.xml
` -->
Sample Push Data Payload
Sample Code that illustrates the problem
Logs taken while reproducing problem
Logs taken from 'Log Cat' from Android Studio
2021-11-29 16:20:54.193 17913-17973/? D/Push_FCMService: onMessage - from: 54689968372 2021-11-29 16:20:54.206 17913-17973/? D/Push_FCMService: sender id = 54689968372 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: normalize extras 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: key = actions 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: replace key actions with actions 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: key = id 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: replace key id with id 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: key = cat 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: replace key cat with cat 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: key = notId 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: replace key notId with notId 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: key = title 2021-11-29 16:20:54.207 17913-17973/? D/Push_FCMService: replace key title with title 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: no locale found for key = title, error Value Ora of type java.lang.String cannot be converted to JSONObject 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: key = message 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: replace key message with message 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: no locale found for key = message, error Value <ul><li>SHATUSH< of type java.lang.String cannot be converted to JSONObject 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: key = compositeIdEventId 2021-11-29 16:20:54.208 17913-17973/? D/Push_FCMService: replace key compositeIdEventId with compositeIdEventId 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: background 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: message =[<ul><li>campo 1<\/li><li>CAMPO 2<\/li><\/ul><\/br> - LISA - 01\/12\/2021 16:10] 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: title =[Ora puoi confermare il tuo Appuntamento!] 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: contentAvailable =[null] 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: forceStart =[null] 2021-11-29 16:20:54.216 17913-17973/? D/Push_FCMService: create notification 2021-11-29 16:20:54.223 17913-17973/? D/Push_FCMService: Using channel ID = PushPluginChannel 2021-11-29 16:20:54.231 17913-17973/? D/Push_FCMService: stored icon=null 2021-11-29 16:20:54.232 17913-17973/? D/Push_FCMService: stored iconColor=null 2021-11-29 16:20:54.232 17913-17973/? D/Push_FCMService: stored sound=true 2021-11-29 16:20:54.232 17913-17973/? D/Push_FCMService: stored vibrate=true 2021-11-29 16:20:54.232 17913-17973/? D/Push_FCMService: no icon resource found - using application icon 2021-11-29 16:20:54.243 17913-17973/? D/Push_FCMService: create actions: with in-line 2021-11-29 16:20:54.489 4278-4278/? E/music: Blocked onNotificationPosted StatusBarNotification(pkg=com.companyname.appname user=UserHandle{0} id=5 tag=AppName key=0|com.companyname.appname|5|AppName|10475: Notification(channel=PushPluginChannel shortcut=null contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)) 2021-11-29 16:20:57.773 1327-2887/? I/ActivityTaskManager: START u0 {flg=0x24000000 cmp=com.companyname.appname/com.adobe.phonegap.push.PushHandlerActivity (has extras)} from uid 10475 2021-11-29 16:20:57.774 1327-2887/? W/ActivityTaskManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { flg=0x24000000 cmp=com.companyname.appname/com.adobe.phonegap.push.PushHandlerActivity (has extras) } 2021-11-29 16:20:57.823 17913-17913/? D/Push_HandlerActivity: not id = 5 2021-11-29 16:20:57.823 17913-17913/? V/Push_HandlerActivity: onCreate 2021-11-29 16:20:57.823 17913-17913/? D/Push_HandlerActivity: callback = null 2021-11-29 16:20:57.824 17913-17913/? D/Push_HandlerActivity: dismissed = false 2021-11-29 16:20:57.829 17913-17913/? V/Push_Plugin: sendExtras: caching extras to send at a later time. 2021-11-29 16:20:57.829 17913-17913/? D/Push_HandlerActivity: bringToForeground = true 2021-11-29 16:20:57.847 17913-17913/? D/Push_HandlerActivity: isPushPluginActive = false 2021-11-29 16:20:57.847 17913-17913/? D/Push_HandlerActivity: forceMainActivityReload 2021-11-29 16:20:58.204 17913-17913/? D/PluginManager: startupPlugins: put - PushNotification 2021-11-29 16:20:58.294 4278-6029/? E/music: onNotificationRemoved... StatusBarNotification(pkg=com.companyname.appname user=UserHandle{0} id=5 tag=AppName key=0|com.companyname.appname|5|AppName|10475: Notification(channel=PushPluginChannel shortcut=null contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)) 2021-11-29 16:21:01.233 17913-18154/? D/PluginManager: getPlugin - put: PushNotification 2021-11-29 16:21:01.233 17913-18154/? V/Push_Plugin: execute: action=hasPermission 2021-11-29 16:21:01.238 17913-18156/? D/Push_Plugin: has permission: true 2021-11-29 16:21:01.372 17913-18154/? V/Push_Plugin: execute: action=init 2021-11-29 16:21:01.373 17913-18156/? V/Push_Plugin: execute: data=[{"android":{}}] 2021-11-29 16:21:01.374 17913-18156/? V/Push_Plugin: execute: jo={} 2021-11-29 16:21:01.375 17913-18156/? V/Push_Plugin: execute: senderID=54689968372 2021-11-29 16:21:01.376 17913-18156/? V/Push_Plugin: onRegistered: {"registrationId":"hidden4privacy","registrationType":"FCM"} 2021-11-29 16:21:01.376 17913-18156/? D/Push_Plugin: no icon option 2021-11-29 16:21:01.376 17913-18156/? D/Push_Plugin: no iconColor option 2021-11-29 16:21:01.377 17913-18156/? V/Push_Plugin: sending cached extras 2021-11-29 16:21:01.377 17913-18156/? D/Push_Plugin: convert extras to json 2021-11-29 16:21:01.377 17913-18156/? D/Push_Plugin: key = actions 2021-11-29 16:21:01.377 17913-18156/? D/Push_Plugin: key = actionCallback 2021-11-29 16:21:01.377 17913-18156/? D/Push_Plugin: key = id 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = cat 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = notId 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = title 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = dismissed 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = message 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = compositeIdEventId 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = coldstart 2021-11-29 16:21:01.378 17913-18156/? D/Push_Plugin: key = foreground 2021-11-29 16:21:01.379 17913-18156/? V/Push_Plugin: extrasToJSON: {"title":"Titolo del messaggio","message":"<ul><li>campo 1<\/li><li>CAMPO 2<\/li><\/ul><\/br> - LISA - 01\/12\/2021 16:10","additionalData":{"actions":[],"id":"29887068","cat":"EVENT_TO_CONFIRM","notId":"5","dismissed":false,"compositeIdEventId":"29887068","coldstart":true,"foreground":false}} 2021-11-29 16:21:07.421 17913-18154/? V/Push_Plugin: execute: action=hasPermission 2021-11-29 16:21:07.422 17913-18156/? D/Push_Plugin: has permission: true