Always trigger an event when receiving notification, received data not important
MauPoLom opened this issue · 2 comments
Expected Behaviour
Only Android:
To monitor our notification-service overall I want to create a logger app that monitors and logs all our notifications. The data that is sent is not important. The app will typically receive 1 or 2 notifications a day.
The logger simply writes to the storage a date and time '201910101827'
99.999% the app wil be running in the background, it has no other function.
Is there a way to trigger the 'on notification' event not matter what (background, foreground, payload), so I can write to the log?
Actual Behaviour
100% of the time the 'on notification' in JS event is only triggered when the incoming notification icon is pushed on the screen.
Reproduce Scenario (including but not limited to)
I've applied several scenarios suggested by other users in other cases like
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
ANDROID 8
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
Samsung galaxy S8
Cordova CLI version and cordova platform version
9.0.0 (cordova-lib@9.0.1)
Installed platforms:
android 8.1.0
Plugin version
Phonegap-plugin-push 2.3.0
Sample Push Data Payload
'''
body = "Hi john, your customized news for today is ready"
Sending a notification with data message payload
These are examples taken from several suggestions. Some are commented out for quick testing
data = {
"title": "Test Notification",
"body": "This offer expires at 11:30 or whatever",
"notId": 10,
"surveyID": "ewtawgreg-gragrag-rgarhthgbad"
}
To a single device
result = push_service.notify_single_device(registration_id=registration_id, message_body=body, data_message=data)
Sending a data message only payload, do NOT include message_body also do NOT include notification body
#result = push_service.single_device_data_message(registration_id=registration_id, data_message=data)
print (result)
'''
message_data = {
"data": {
"title": "Test Notification",
"body": "This offer expires at 11:30 or whatever",
"notId": 10,
"surveyID": "ewtawgreg-gragrag-rgarhthgbad"
}
}
result = push_service.single_device_data_message(registration_id=registration_id, data_message=message_data)
Thank you for looking into this
Sorry for any grammar or mistakes I made writing this all down..
Let's try our plugin addon
https://github.com/RoboFinance/CordovaPushDelivery
Sorry for my late response. I'll give it a try. Thank You