Push Notifications: How can I send extra parameters in push notification data? I am using Push Notifications module to send notification to registered tokens.

I am able to send a plain text notification successfully via rules. 

I am looking for a way to send the notification with extra fields so that it can be identified which type of notification is this and what action to take on this.

Below is the data example I need to send the notification in:

{
   "aps":{
      "alert": "Enter your message",
      "badge":1,
      "sound":"default",

     "extraField 1":"some value",
     "extraField2":"identifier"
   }
}


Here is the rule export:

    { 
    "rules_push_notification" : {
    "LABEL" : "Push Notification",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "push_notifications" ],
    "ON" : { "node_insert" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "music" : "music", "news" : "news" } }
        }
      }
    ],
    "DO" : [
      { "push_notifications_send_message_bulk" : { "message" : "[node:title]", "target_group" : "authenticated" } }
    ]
  }
}


Notes: 


My Rules Action maps (corresponds) to the data example like so: that "Enter your message" would be replaced by the value of "[node:title]".
About that "extra field 1" (and "extra field 2"): When I send a Push notification, On Tap it needs some action to be taken which is decided in those extra fields, for an example if I need to show a music article I will send "music" as identifier and second field will be the node id of the content help mobile to open that particular article.
The current D7 release of the Push Notifications module does not allow/support such extra fields (as in your question). However below are some suggestions to get you closer ...

Integrate 'identifier' in your Alert message

You could produce 2 types of alert messages, based on the content type (= News or Music), by adapting your Rules Action. This by also integrating the available [node:content-type] token, it could look something like so:

      { "push_notifications_send_message_bulk" :
        { "message" : "[node:content-type] notification: [node:title]",
          "target_group" : "authenticated" } }


Using this approach, your message starts to look like a kind of transaction to be processed, for which there might be solutions to further process it on your target platform).

Integrate 'some value' in your Alert message

Using a similar approach, you could further extend this to also include that "some value" related to your "extraField 1" (as in your question), probably you'd want to use the available [node:nid] token for that.

However, as per your comment (="it will appear {1234 (nid)} / {music (node type)} / The title (The title of the node) which does not looks good actually."), you may want to try another approach (as explained in the next suggestion).

Send JSON messages

Your data example seems to be a variation of what's shown in the issue about "sending JSON messages", in which the notification message is a JSON string that looks like so:

{"title": "my title",
 "message": "my message",
 "additionalData": { "key": "value", ... }}


Comment #3 in that issue refers to the issue about "Custom Payloads for Push Notifications", and which includes a patch (current status = needs review) with which you might get it to work somehow.

Upcoming improvements in D8

Help is on its way, as detailed in the D8 related issue about "Create content entity for push notifications".