That is, can you send
{
"registration_ids": ["whatever", ...],
"data": {
"foo": {
"bar": {
"baz": [42]
}
}
}
}
or is the “data” member of the GCM request restricted to one level of key-value pairs? I ask b/c that limitation is suggested by the wording in Google’s doc[1], where it says “data” is:
A JSON object whose fields represents the key-value pairs of the message’s payload data. If present, the payload data it will be included in the Intent as application data, with the key being the extra’s name. For instance, “data”:{“score”:”3×1″} would result in an intent extra named score whose value is the string 3×1 There is no limit on the number of key/value pairs, though there is a limit on the total size of the message. Optional.
[1] http://developer.android.com/guide/google/gcm/gcm.html#request
Just did a test myself and confirmed my conjecture.
Send a GCM to myself with this payload:
And my client received it and parse the ‘message’ intent extra as this:
So the you can indeed do further JSON parsing on the value of a data key.