android - GCM not using data from JSON payload in the notification -


i sending following json through gcm (google cloud messaging) have not been able right response data through client. push notification response, title app's name, , texts reads: "message" can't display notification properly.

here json trying send:

{     "to": "somekey",   "notification": {         "body":"test",       "title":"test"   },   "data": null } 

i think problem on key-values of payload of message.

as can see @ gcm server documentation, payload can set using 2 different keys:

  • data: parameter specifies key-value pairs of message's payload.
  • notification: parameter specifies key-value pairs of notification payload.

you should use data key , set inside payload of notification. once send, can print result of notification received , see there right payload inside data key.

your message should following json data:

{   "registration_ids" => "some_target_device_id",   "data": {       "title": "my title",       "message": "this message!",   } } 

Comments