Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

notification event not fired on cold start on Android 5 #469

Closed
TonivdW opened this issue Jan 2, 2016 · 9 comments
Closed

notification event not fired on cold start on Android 5 #469

TonivdW opened this issue Jan 2, 2016 · 9 comments

Comments

@TonivdW
Copy link

TonivdW commented Jan 2, 2016

I have two Android test-devices, one is on Android 4.4.4 and the other one is running 5.1.1.
If the app is running in foreground then the notification even is fired ok.
If I send a notification to those devices the message is received and processed while the app is running in background. No problems there.
(CORRECTION: further testing shows that the notification event is also not fired when the app is backgrounded)

If the app is not running at all the notification is received by the device and shown in the statusbar. Clicking it opens the app ok. But only on the Android 4 device the notification event is subsequently delivered to the app. On the Android 5 device the event is not fired.
(I'm building with Cordova 5.4.1 and am using the 1.5.2 version of plugin)

@TonivdW
Copy link
Author

TonivdW commented Jan 2, 2016

Maybe this helps: output of adb logcat|grep -i pushplugin
on Android 5:
(nothing logged upon reception of the notification)
after clicking on the notification:

V/PushPlugin(21580): execute: action=hasPermission
V/PushPlugin(21580): execute: action=init
V/PushPlugin(21580): execute: data=[{"android":{"senderID":"xxx","icon":"nficon"}}]
V/PushPlugin(21580): execute: jo={"senderID":"xxx","icon":"nficon"}
V/PushPlugin(21580): execute: senderID=xxx
V/PushPlugin(21580): onRegistered: {"registrationId":"xxx"}
D/PushPlugin(21580): no iconColor option

on Android 4:
upon receiving the notification:

D/PushPlugin_GCMIntentService(29985): onMessage - from: xxx
D/PushPlugin_GCMIntentService(29985): normalize extras
D/PushPlugin_GCMIntentService(29985): key = foo
D/PushPlugin_GCMIntentService(29985): replace key foo with foo
D/PushPlugin_GCMIntentService(29985): key = notification
D/PushPlugin_GCMIntentService(29985): notifkey = content-available
D/PushPlugin_GCMIntentService(29985): replace key content-available with content-available
D/PushPlugin_GCMIntentService(29985): notifkey = sound2
D/PushPlugin_GCMIntentService(29985): replace key sound2 with sound2
D/PushPlugin_GCMIntentService(29985): notifkey = e
D/PushPlugin_GCMIntentService(29985): replace key e with e
D/PushPlugin_GCMIntentService(29985): notifkey = body
D/PushPlugin_GCMIntentService(29985): replace key body with message
D/PushPlugin_GCMIntentService(29985): notifkey = icon
D/PushPlugin_GCMIntentService(29985): replace key icon with icon
D/PushPlugin_GCMIntentService(29985): notifkey = sound
D/PushPlugin_GCMIntentService(29985): replace key sound with sound
D/PushPlugin_GCMIntentService(29985): notifkey = title
D/PushPlugin_GCMIntentService(29985): replace key title with title
D/PushPlugin_GCMIntentService(29985): notifkey = message
D/PushPlugin_GCMIntentService(29985): replace key message with message
D/PushPlugin_GCMIntentService(29985): notifkey = ledColor
D/PushPlugin_GCMIntentService(29985): replace key ledColor with ledColor
D/PushPlugin_GCMIntentService(29985): key = collapse_key
D/PushPlugin_GCMIntentService(29985): replace key collapse_key with collapse_key
D/PushPlugin_GCMIntentService(29985): background
D/PushPlugin_GCMIntentService(29985): message =[hello world]
D/PushPlugin_GCMIntentService(29985): title =[TTapp]
D/PushPlugin_GCMIntentService(29985): contentAvailable =[1]
D/PushPlugin_GCMIntentService(29985): create notification
E/PushPlugin_GCMIntentService(29985): Number format exception - Error parsing notId: Invalid int: "null"
D/PushPlugin_GCMIntentService(29985): stored icon=nficon
D/PushPlugin_GCMIntentService(29985): stored iconColor=null
D/PushPlugin_GCMIntentService(29985): stored sound=true
D/PushPlugin_GCMIntentService(29985): stored vibrate=true
D/PushPlugin_GCMIntentService(29985): using icon from plugin options
D/PushPlugin_GCMIntentService(29985): create actions
D/PushPlugin_GCMIntentService(29985): send notification event
V/PushPlugin(29985): sendExtras: caching extras to send at a later time.

after clicking the notification:

V/PushPlugin_PushHandlerActivity(29985): onCreate
V/PushPlugin(29985): sendExtras: caching extras to send at a later time.
V/PushPlugin(29985): execute: action=hasPermission
V/PushPlugin(29985): execute: action=init
V/PushPlugin(29985): execute: data=[{"android":{"senderID":"xxx","icon":"nficon"}}]
V/PushPlugin(29985): execute: jo={"senderID":"xxx","icon":"nficon"}
V/PushPlugin(29985): execute: senderID=xxx
V/PushPlugin(29985): onRegistered: {"registrationId":"xxx"}
D/PushPlugin(29985): no iconColor option
V/PushPlugin(29985): sending cached extras
D/PushPlugin(29985): convert extras to json
D/PushPlugin(29985): key = content-available
D/PushPlugin(29985): key = sound2
D/PushPlugin(29985): key = callback
D/PushPlugin(29985): key = e
D/PushPlugin(29985): key = foo
D/PushPlugin(29985): key = icon
D/PushPlugin(29985): key = sound
D/PushPlugin(29985): key = title
D/PushPlugin(29985): key = message
D/PushPlugin(29985): key = ledColor
D/PushPlugin(29985): key = coldstart
D/PushPlugin(29985): key = collapse_key
D/PushPlugin(29985): key = foreground
V/PushPlugin(29985): extrasToJSON: {"message":"hello world","additionalData":{"icon":"nficon","collapse_key":"nl.ttapp","e":"1","content-available":"1","coldstart":true,"foo":"bar","ledColor":[0,0,0,255],"sound2":"default","foreground":false},"title":"TTapp","sound":"default"}

@rlloyd2001
Copy link

I'm seeing this same problem with Android 5.1.1.

@TonivdW
Copy link
Author

TonivdW commented Jan 11, 2016

The hint in #490 seems to have saved my day: I have now put all the information in data instead of notification and now all of a sudden it all seems to work. Background, foreground and coldstart, on both Android 4 and Android 5 devices it now appears to work! I will make further tests. Maybe the docs should be clearer on what to put where in the GCM message.

@macdonst
Copy link
Member

@TonivdW yes, I do need to do better on the docs.

@TonivdW
Copy link
Author

TonivdW commented Jan 12, 2016

I have done some more testing and I can now confirm that all issues described above disappeared once I started putting all the information in the data element instead of in notification.
I am now taking the plunge and incorporate this plugin into a production version of my app. Fingers crossed...
@macdonst : shall I leave this issue open for the docs-issue?

@macdonst
Copy link
Member

@TonivdW no, I'm going to close it as I already know what needs to be done and it's being tracked elsewhere.

@Nitingadhiya
Copy link

hi , i am using cordova android . i am some issue found . wjen application is closed notification is not recive on device. how to solve my problem?

@qasmaoui
Copy link

qasmaoui commented Oct 6, 2017

hello simple solution is
when you send payload sendt it like this ( in php )

use data instead of notification

change this

 $msg = array
          (
		'body' 	=> $bodym,
		'title'	=> 'title',
         'vibrate' => 1,
          'sound' => 'default',
          );
	$fields = array
			(
				'registration_ids' =>$registrationIds,
				'notification'	=> $msg,
				
			);

to this

 $msg = array
          (
		'body' 	=> $bodym,
		'title'	=> 'title',
         'vibrate' => 1,
          'sound' => 'default',
          );
	$fields = array
			(
				'registration_ids' =>$registrationIds,
				'data'	=> $msg,
				
			);

this should fire on.notification in clod start

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants