Open F1LT3R opened 6 years ago
Update:
I found that GCM over Amazon SNS Console, does work on Android 8.0 without upgrading to FCM, but you have to use a slightly different message format.
On older versions of Android, you can use data
as your message attribute:
{
"GCM": "{ \"data\": { \"text\": \"test message\" } }"
}
But on Android 8.0 you have to change data
to notification
:
{
"GCM": "{ \"notification\": { \"text\": \"test message\" } }"
}
I discovered this in a Stack Overflow: https://stackoverflow.com/questions/38300450/fcm-with-aws-sns
I found that I did not have to follow all the steps that the posted recommended, but just update the message format.
Perhaps this should be included in the phonegap-push-plugin
documentation? (I'm guessing this question is going to start coming up more in the future)
Hi @F1LT3R could you help me to show the notification, only shows the notification icon at status bar, but is not showing the notification like whatsApp
@F1LT3R if you use the notification part of the payload then the onMessageReceived
method of the plugin will not be called so that is why your background notification is not working.
As the link to your SO question mentions However, if you are sending data payloads to the Android device they will not be processed unless you implement a client side service that extends FirebaseMessagingService
which is true but this plugin does implement a FirebaseMessagingService
.
I'd rather see some logs while you are reproducing the problem adb logcat | grep Push
.
@macdonst, just to make sure we are talking about the same thing, when I use notification
I do see an Android 8.0 notification for the following scenarios:
I receive the message here in the JavaScript:
push.on('notification', function (data) {
console.log(data)
alert('Event=notification, message=' + data.message)
});
In this case, my Amazon SNS Console payload is:
{
"GCM": "{ \"notification\": { \"text\": \"test message\" } }"
}
I will try to get you those logs.
@iknox27, that is working automatically for me. I think that's called a "Badge"? Are you not seeing the badge if you push the notification with the app closed?
@F1LT3R yes, we are talking about the same thing. You are seeing the push message but if you want to use the more interesting part of this plugin like action buttons, sound, images, etc. you'll have to use a data
payload.
When you use a notification
payload the OS takes over and never lets the plugin know that a push has arrived.
Ok. Thanks, @macdonst.
adb logcat | grep Push
# [1] 6183 terminated adb logcat |
# 6184 exit 1 grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} Push
After that my device seems offline: (I have not seen this offline thing before)
adb devices
# List of devices attached
# 711KPZK0695877 offline
Oddly, if I disable and re-enable developer mode, I do see the grep, but it instantly exits.
Here is what I have:
- waiting for device -
01-23 20:17:16.620 1103 1676 W ActivityManager: Scheduling restart of crashed service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0 in 1000ms
01-23 20:17:16.861 1103 3087 I WindowManager: WIN DEATH: Window{e59239d u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity}
01-23 20:17:16.862 1103 11657 I ActivityManager: Process org.apache.cordova.RemotePushNotificationsApp (pid 8976) has died: cch+1CAC
01-23 20:18:11.026 1103 1136 I ActivityManager: Start proc 23387:org.apache.cordova.RemotePushNotificationsApp/u0a239 for broadcast org.apache.cordova.RemotePushNotificationsApp/com.google.firebase.iid.FirebaseInstanceIdReceiver
01-23 20:21:02.163 1103 1120 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[586,1702][855,2096]} from uid 10052
01-23 20:21:02.336 1103 11650 I ActivityManager: Start proc 24067:com.android.chrome:sandboxed_process0/u0i15 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-23 20:22:37.474 1103 1120 I ActivityManager: Killing 23387:org.apache.cordova.RemotePushNotificationsApp/u0a239 (adj 900): remove task
01-23 20:22:37.494 1103 11646 W ActivityManager: Scheduling restart of crashed service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0 in 1000ms
01-23 20:22:37.512 1103 11651 I WindowManager: WIN DEATH: Window{8ad6c16 u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity}
01-23 20:22:38.227 1103 11650 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[586,1702][855,2096]} from uid 10052
01-23 20:22:38.244 1103 3088 I ActivityManager: Start proc 24197:org.apache.cordova.RemotePushNotificationsApp/u0a239 for activity org.apache.cordova.RemotePushNotificationsApp/.MainActivity
01-23 20:22:38.432 1103 2927 I ActivityManager: Start proc 24220:com.android.chrome:sandboxed_process0/u0i16 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-23 20:24:45.108 1103 11651 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 pkg=org.apache.cordova.RemotePushNotificationsApp cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity (has extras)} from uid 10239
01-23 20:24:47.930 1103 3088 I WindowManager: Failed to capture screenshot of Token{230749c ActivityRecord{15cdc0f u0 org.apache.cordova.RemotePushNotificationsApp/.MainActivity t1765}} appWin=Window{bafd0df u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity} drawState=4
01-23 20:25:26.971 1103 2789 I ActivityManager: Killing 24197:org.apache.cordova.RemotePushNotificationsApp/u0a239 (adj 900): remove task
01-23 20:25:27.012 1103 2927 W ActivityManager: Scheduling restart of crashed service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0 in 1000ms
01-23 20:25:27.025 1103 3088 I WindowManager: WIN DEATH: Window{bafd0df u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity}
01-23 20:25:41.288 1103 1136 I ActivityManager: Start proc 26268:org.apache.cordova.RemotePushNotificationsApp/u0a239 for broadcast org.apache.cordova.RemotePushNotificationsApp/com.google.firebase.iid.FirebaseInstanceIdReceiver
01-23 20:33:08.792 1103 11647 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[586,1702][855,2096]} from uid 10052
01-23 20:33:08.906 1103 11646 I ActivityManager: Start proc 27928:com.android.chrome:sandboxed_process0/u0i17 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-23 22:23:44.256 1103 1136 I ActivityManager: Force stopping org.apache.cordova.RemotePushNotificationsApp appid=10239 user=-1: installPackageLI
01-23 22:23:44.256 1103 1136 I ActivityManager: Killing 26268:org.apache.cordova.RemotePushNotificationsApp/u0a239 (adj 903): stop org.apache.cordova.RemotePushNotificationsApp
01-23 22:23:44.271 1103 1136 I ActivityManager: Force finishing activity ActivityRecord{aa92264 u0 org.apache.cordova.RemotePushNotificationsApp/.MainActivity t1766}
01-23 22:23:44.337 1103 1148 I PackageManager: Package org.apache.cordova.RemotePushNotificationsApp codePath changed from /data/app/org.apache.cordova.RemotePushNotificationsApp-wljPi9mmIWsZfrUNPQCmzw== to /data/app/org.apache.cordova.RemotePushNotificationsApp-MfhdnRBsomjulrh2M6Sgig==; Retaining data and using new
01-23 22:23:44.337 1103 1148 W PackageManager: Code path for org.apache.cordova.RemotePushNotificationsApp changing from /data/app/org.apache.cordova.RemotePushNotificationsApp-wljPi9mmIWsZfrUNPQCmzw== to /data/app/org.apache.cordova.RemotePushNotificationsApp-MfhdnRBsomjulrh2M6Sgig==
01-23 22:23:44.337 1103 1148 W PackageManager: Resource path for org.apache.cordova.RemotePushNotificationsApp changing from /data/app/org.apache.cordova.RemotePushNotificationsApp-wljPi9mmIWsZfrUNPQCmzw== to /data/app/org.apache.cordova.RemotePushNotificationsApp-MfhdnRBsomjulrh2M6Sgig==
01-23 22:23:44.563 1103 1148 I ActivityManager: Force stopping org.apache.cordova.RemotePushNotificationsApp appid=10239 user=0: pkg removed
01-23 22:23:44.570 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.android.musicfx/.Compatibility$Receiver
01-23 22:23:44.825 1103 11646 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.enterprise.dmagent/.AppUpdateReceiver
01-23 22:23:44.859 1103 11646 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
01-23 22:23:44.879 1103 11646 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.android.musicfx/.Compatibility$Receiver
01-23 22:23:44.889 1103 11645 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.enterprise.dmagent/.AppUpdateReceiver
01-23 22:23:44.890 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.enterprise.dmagent/com.google.android.apps.work.dpcsupport.AccountManagementWhitelistEnforcer$ContinuousEnforcer
01-23 22:23:44.944 1103 2927 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
01-23 22:23:45.035 1103 11644 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.android.musicfx/.Compatibility$Receiver
01-23 22:23:45.036 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.enterprise.dmagent/.AppUpdateReceiver
01-23 22:23:45.036 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.photos/.account.full.FetchAccountPropertiesAppUpgradeBroadcastReceiver
01-23 22:23:45.036 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.photos/.backgroundsignin.BackgroundSignInBroadcastReceiver
01-23 22:23:45.036 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.photos/.experiments.phenotype.full.PhenotypeAppUpgradeBroadcastReceiver
01-23 22:23:45.036 1103 1136 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.apps.photos/.notificationchannels.AppUpdateBroadcastReceiver
01-23 22:23:45.049 1103 2927 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:org.apache.cordova.RemotePushNotificationsApp flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
01-23 22:23:45.403 1103 11644 I ActivityManager: START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity} from uid 2000
01-23 22:23:45.423 1103 11656 I ActivityManager: Start proc 26516:org.apache.cordova.RemotePushNotificationsApp/u0a239 for activity org.apache.cordova.RemotePushNotificationsApp/.MainActivity
01-23 22:23:45.669 1103 11654 I ActivityManager: Start proc 26545:com.android.chrome:sandboxed_process0/u0i20 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-23 23:04:20.525 1103 11648 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 pkg=org.apache.cordova.RemotePushNotificationsApp cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity (has extras)} from uid 10239
01-24 00:06:54.182 19069 19095 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:06:54.193 19069 19105 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:06:54.203 19069 19113 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:15:18.848 26516 9569 D Push_FCMService: onMessage - from: 111122223333
01-24 00:15:18.850 26516 9569 D Push_FCMService: normalize extras
01-24 00:15:18.852 26516 9569 D Push_FCMService: key = text
01-24 00:15:18.853 26516 9569 D Push_FCMService: replace key text with text
01-24 00:15:18.853 26516 9569 D Push_FCMService: background
01-24 00:15:18.854 26516 9569 D Push_FCMService: message =[null]
01-24 00:15:18.854 26516 9569 D Push_FCMService: title =[null]
01-24 00:15:18.854 26516 9569 D Push_FCMService: contentAvailable =[null]
01-24 00:15:18.854 26516 9569 D Push_FCMService: forceStart =[null]
01-24 00:15:24.482 1550 1550 W StatusBar: removeNotification for unknown key: 0|org.apache.cordova.RemotePushNotificationsApp|0|FCM-Notification:16803869|10239
01-24 00:15:36.950 26516 9569 D Push_FCMService: onMessage - from: 111122223333
01-24 00:15:36.954 26516 9569 D Push_FCMService: normalize extras
01-24 00:15:36.954 26516 9569 D Push_FCMService: key = text
01-24 00:15:36.954 26516 9569 D Push_FCMService: replace key text with text
01-24 00:15:36.954 26516 9569 D Push_FCMService: background
01-24 00:15:36.955 26516 9569 D Push_FCMService: message =[null]
01-24 00:15:36.955 26516 9569 D Push_FCMService: title =[null]
01-24 00:15:36.955 26516 9569 D Push_FCMService: contentAvailable =[null]
01-24 00:15:36.955 26516 9569 D Push_FCMService: forceStart =[null]
01-24 00:16:58.344 1103 11659 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[48,126][317,520]} from uid 10052
01-24 00:20:12.490 1103 11653 I ActivityManager: Killing 26516:org.apache.cordova.RemotePushNotificationsApp/u0a239 (adj 900): remove task
01-24 00:20:12.507 1103 11652 W ActivityManager: Scheduling restart of crashed service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0 in 1000ms
01-24 00:20:12.530 1103 2927 I WindowManager: WIN DEATH: Window{a7c4910 u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity}
01-24 00:20:30.523 1103 1120 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[48,126][317,520]} from uid 10052
01-24 00:20:30.553 1103 2789 I ActivityManager: Start proc 22655:org.apache.cordova.RemotePushNotificationsApp/u0a239 for activity org.apache.cordova.RemotePushNotificationsApp/.MainActivity
01-24 00:20:30.658 22655 22655 I FA : adb shell setprop debug.firebase.analytics.app org.apache.cordova.RemotePushNotificationsApp
01-24 00:20:30.819 1103 2927 I ActivityManager: Start proc 22678:com.android.chrome:sandboxed_process0/u0i21 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-24 00:20:31.102 1103 1143 I ActivityManager: Displayed org.apache.cordova.RemotePushNotificationsApp/.MainActivity: +561ms
01-24 00:20:31.131 22655 22748 W cr_CrashFileManager: /data/user/0/org.apache.cordova.RemotePushNotificationsApp/cache/WebView/Crash Reports does not exist or is not a directory
01-24 00:20:31.421 22655 22752 V Push_Plugin: execute: action=init
01-24 00:20:31.423 22655 22754 V Push_Plugin: execute: data=[{"android":{"senderID":111122223333},"browser":{"pushServiceURL":"http:\/\/push.api.phonegap.com\/v1\/push"},"ios":{"alert":"true","badge":"true","sound":"true"},"windows":{}}]
01-24 00:20:31.424 22655 22754 V Push_Plugin: execute: jo={"senderID":111122223333}
01-24 00:20:31.424 22655 22754 V Push_Plugin: execute: senderID=111122223333
01-24 00:20:31.425 22655 22754 V Push_Plugin: onRegistered: {"registrationId":"daZx..registrationId..Dqp0"}
01-24 00:20:31.427 22655 22754 D Push_Plugin: no icon option
01-24 00:20:31.427 22655 22754 D Push_Plugin: no iconColor option
01-24 00:20:31.487 610 610 D SurfaceFlinger: duplicate layer name: changing org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity to org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity#1
I tried to push messages with the data
key again.
{
"GCM": "{ \"data\": { \"text\": \"test message\" } }"
}
Pushing with data
attribute to foreground I get:
01-24 00:26:10.085 22655 26011 D Push_FCMService: onMessage - from: 111122223333
01-24 00:26:10.085 22655 26011 D Push_FCMService: normalize extras
01-24 00:26:10.085 22655 26011 D Push_FCMService: key = text
01-24 00:26:10.086 22655 26011 D Push_FCMService: replace key text with text
01-24 00:26:10.086 22655 26011 D Push_FCMService: foreground
01-24 00:26:10.086 22655 26011 D Push_Plugin: convert extras to json
01-24 00:26:10.086 22655 26011 D Push_Plugin: key = text
01-24 00:26:10.086 22655 26011 D Push_Plugin: key = coldstart
01-24 00:26:10.086 22655 26011 D Push_Plugin: key = foreground
01-24 00:26:10.086 22655 26011 V Push_Plugin: extrasToJSON: {"additionalData":{"text":"FOOBAR","coldstart":false,"foreground":true}}
01-24 00:26:10.133 610 610 D SurfaceFlinger: duplicate layer name: changing org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity to org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity#1
And I see the notification Alert in the app, via:
push.on('notification', function (data) {
console.log(data)
alert('Event=notification, message=' + data.message)
});
@F1LT3R right, what you have described above is what I expect to happen.
Right, so killing the app, and pushing the same again, I get the following output after I start the app back up...
(this is the logs that have appeared after the last line from my previous comment)
a.RemotePushNotificationsApp.MainActivity to org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity#1
01-24 00:27:45.198 26765 26788 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:27:45.219 26765 26793 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:27:45.237 26765 26794 I Bugle : Carrier configs loaded: Bundle[{httpSocketTimeout=60000, aliasMinChars=2, smsToMmsTextThreshold=-1, enableSMSDeliveryReports=true, maxMessageTextSize=-1, supportMmsContentDisposition=true, enabledTransID=false, aliasEnabled=false, supportHttpCharsetHeader=false, allowAttachAudio=true, spamForwardingNumber=7726, smsToMmsTextLengthThreshold=-1, recipientLimit=2147483647, uaProfTagName=x-wap-profile, aliasMaxChars=48, maxImageHeight=1944, enableMMSDeliveryReports=false, userAgent=, mmsCloseConnection=true, config_cellBroadcastAppLinks=true, maxSubjectLength=40, httpParams=, enableGroupMms=true, allowEnablingWapPushSI=false, emailGatewayNumber=, maxMessageSize=1048576, naiSuffix=, enableMMSReadReports=false, maxImageWidth=2592, uaProfUrl=, enabledMMS=true, enabledNotifyWapMMSC=false, enableWapPushSI=true, sendMultipartSmsAsSeparateMessages=false, enableMultipartSMS=true}] from resources+system for subId=1
01-24 00:29:05.448 1103 11656 I ActivityManager: Killing 22655:org.apache.cordova.RemotePushNotificationsApp/u0a239 (adj 900): remove task
01-24 00:29:05.488 1103 2926 W ActivityManager: Scheduling restart of crashed service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0 in 1000ms
01-24 00:29:05.503 1103 1120 I WindowManager: WIN DEATH: Window{869f44a u0 org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity}
01-24 00:29:41.538 1103 1136 I ActivityManager: Start proc 26941:org.apache.cordova.RemotePushNotificationsApp/u0a239 for broadcast org.apache.cordova.RemotePushNotificationsApp/com.google.firebase.iid.FirebaseInstanceIdReceiver
01-24 00:29:41.711 26941 26941 I FA : adb shell setprop debug.firebase.analytics.app org.apache.cordova.RemotePushNotificationsApp
01-24 00:29:41.740 26941 26961 D Push_FCMService: onMessage - from: 111122223333
01-24 00:29:41.753 26941 26961 D Push_FCMService: normalize extras
01-24 00:29:41.753 26941 26961 D Push_FCMService: key = text
01-24 00:29:41.754 26941 26961 D Push_FCMService: replace key text with text
01-24 00:29:41.754 26941 26961 D Push_FCMService: background
01-24 00:29:41.754 26941 26961 D Push_FCMService: message =[null]
01-24 00:29:41.754 26941 26961 D Push_FCMService: title =[null]
01-24 00:29:41.755 26941 26961 D Push_FCMService: contentAvailable =[null]
01-24 00:29:41.755 26941 26961 D Push_FCMService: forceStart =[null]
01-24 00:30:58.650 1103 1120 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.apache.cordova.RemotePushNotificationsApp/.MainActivity bnds=[48,126][317,520]} from uid 10052
01-24 00:30:58.769 1103 11655 I ActivityManager: Start proc 27563:com.android.chrome:sandboxed_process0/u0i22 for webview_service org.apache.cordova.RemotePushNotificationsApp/org.chromium.content.app.SandboxedProcessService0
01-24 00:30:58.938 1103 1143 I ActivityManager: Displayed org.apache.cordova.RemotePushNotificationsApp/.MainActivity: +278ms
01-24 00:30:58.950 26941 27624 W cr_CrashFileManager: /data/user/0/org.apache.cordova.RemotePushNotificationsApp/cache/WebView/Crash Reports does not exist or is not a directory
01-24 00:30:59.101 26941 27627 V Push_Plugin: execute: action=init
01-24 00:30:59.104 26941 27634 V Push_Plugin: execute: data=[{"android":{"senderID":111122223333},"browser":{"pushServiceURL":"http:\/\/push.api.phonegap.com\/v1\/push"},"ios":{"alert":"true","badge":"true","sound":"true"},"windows":{}}]
01-24 00:30:59.105 26941 27634 V Push_Plugin: execute: jo={"senderID":111122223333}
01-24 00:30:59.105 26941 27634 V Push_Plugin: execute: senderID=111122223333
01-24 00:30:59.107 26941 27634 V Push_Plugin: onRegistered: {"registrationId":"daZx...regId...Dqp0"}
01-24 00:30:59.108 26941 27634 D Push_Plugin: no icon option
01-24 00:30:59.108 26941 27634 D Push_Plugin: no iconColor option
01-24 00:30:59.165 610 610 D SurfaceFlinger: duplicate layer name: changing org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity to org.apache.cordova.RemotePushNotificationsApp/org.apache.cordova.RemotePushNotificationsApp.MainActivity#1
As far as I can tell... it looks like it is getting "something" over FCM while backgrounded. But I do not see data
or test message
any longer. It's this point at which I am stuck.
I do not receive a message if I post with this while the app is backgrounded:
{
"GCM": "{\"data\" : { \"title\": \"Test Notification\", \"body\": \"This offer expires at 11:30 or whatever\", \"notId\": 10, \"surveyID\": \"ewtawgreg-gragrag-rgarhthgbad\"}}"
}
But I do receive the message if I post the above while the app is in the foreground.
I got the above code from Notifications vs. Data Payloads section: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads
--- BEGIN QUOTE --- My recommended format for your push payload when using this plugin (while it differs from Google's docs) works 100% of the time:
{
"data" : {
"title": "Test Notification",
"body": "This offer expires at 11:30 or whatever",
"notId": 10,
"surveyID": "ewtawgreg-gragrag-rgarhthgbad"
}
}
--- END QUOTE ---
@F1LT3R after you kill the app, are you seeing the notification in the shade?
Unfortunately not.
If it is helpful, I posted the complete list of steps I used here: Setting Up Amazon SNS & Apache Cordova for Push Notifications
I've been hitting this issue as well. We've not yet updated our Cordova stack to build for Android 8 because push notifications don't display in the background. From what it looks like, we need to add the notification
property in the payload, even though the docs say we don't.
@F1LT3R @ehorodyski I found out what was causing the problem and I'm looking into a fix right now. Should have something out today.
@F1LT3R @ehorodyski nope, sorry. False alarm. I forgot to clear the shared preferences which was giving me a false negative. I'm testing this on my 8.0 and 8.1 phones and can't reproduce. Can you try testing without Amazon SNS? For instance can you use the following node script to help debug.
const FCM = require('fcm-node');
// Replace these with your own values.
const apiKey = "replace with API key";
const deviceID = "my device id";
const fcm = new FCM(apiKey);
const message = {
to: deviceID,
data: {
title: 'My Title',
body: 'My Body',
notId: 10,
surveyID: "ewtawgreg-gragrag-rgarhthgbad"
}
};
fcm.send(message, (err, response) => {
if (err) {
console.log(err);
console.log("Something has gone wrong!");
} else {
console.log("Successfully sent with response: ", response);
}
});
Hi! Same problem here. I tried the fcm as well as the gcm approach. Both work fine on Android versions below 8, but there is no notfication on Android 8 when the app is in the background.
I used the config.xml from the tutorial and there is an old version of the plugin specified. Updated the app and the plugin to the newest version. Now it works on Android 8 too.
@F1LT3R i'm using PGB online using following setup:
`
but i'm still getting this error:
Fetching plugin "phonegap-plugin-push@2.2.2" via npm Installing "phonegap-plugin-push" at "2.2.2" for android Plugin doesn't support this project's cordova-android version. cordova-android: 7.0.0, failed version requirement: >=7.1.0 Skipping 'phonegap-plugin-push' for android
What's wrong ? Which version pair android/push-plugin did you use for solve your issue ?
Thanks in advance
@campagna91 PGB does not yet support Android 7.1.0.
Hi @stillatmylinux and thanks for reply.
Yes i know that maximum supported android version is 7 but plugin was installed successfully (apparently by pgb logger) choosing a not last version of phonegap-push-plugin (eg. if i'm not wrong v. 2..1.3).
That above is only one of a lot build done yesterday :D
So, which exact minimum version of phonegap-push-plugin that can be used to receive push on android 8?
Many thanks in advance
I also just started getting this. Push messages to android 8 are either not coming through or are crashing the push notification when it gets received. Just posting here for if anybody finds a solution to this.
Strange, not happening to me. Android 8.1.0, plugin version 2.1.2, notification payload contains both 'notification' and 'data' keys (because of other reasons).
Notification looks fine, app opens fine when I tap it, etc.
Ok, ill give 2.1.2 a try, but i think it might also be due to how my payload is built. May need to change it.
You need to add "content-available": "1" to the data
section:
I'm also experiencing this issue. It's sounding like updating to 2.1.2 may/will fix the issue. However, I have not transitioned to FCM yet. Will 2.1.2 still work with my GCM infrastructure?
@bradeaton I dont know if 2.1.2 still supports GCM but i would recommend you look into switching to FCM as GCM has been depreciated and will end service next year. As for the cause of this issue i still never really found the actual cause, but after testing on FCM it seems to be more reliable.
Edit: Im using 2.1.3 in my next app update and so far during testing i am able to receive push notifications when app is closed, in background and in foreground using FCM.
I have same problem with plugin version 1.11.1, should it work on v1? Pushes not receive on 8 version, but received on 7 android version. I use phonegap builder to build. I send following message format using node-gcm(they say that they use fcm inside) to specific device tokens:
{
"timeToLive" : 86400,
"data" : {
"content-available" : "1",
"notId" : 1398,
"title" : "testtest",
"icon" : "ic_launcher",
"body" : "testtest",
"id" : 1398
}
}
Any help please?
Expected Behaviour
I expect to receive a background notification on Android 8.0.
Actual Behaviour
Steps to Reproduce
Platform, Version, Device, Provider
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload