| This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal. |
#[Informational Post]
How to select 2 different providers for push notification in androidprecompiletask.xml
#Requirement#
How to change the keys dynamically in xml based on the server which is pushing the notification. If both have different response format
Example,
When we push from either KMS console OR from any Thirdparty server console to get the notification, In the notification panel we need to show title and body.
To achieve this generally we will configure the title and body key in androidprecompiletask.xml to match with either KMS or Thirdparty server.
But the Payload from Thirdparty server and KMS console will be different like,
1.Payload from Beanstalk server with title and message attribute.
{
"launchmode": 2,
"launchparams": {
"message": "Sample message",
"google.original_priority": "normal",
"title": "Sample Title ",
"from": "2333"
}
}
2. Payload from KMS console with content as key.
{
"mid": "5186622585630620540",
"google.original_priority": "normal",
"content": "Sample message",
"title": "Sample title",
"from": "23333"
}
In the both the above payloads, there is difference in the keys like "message" in 3rd party and "content" in KMS
If the requirement is configure the both the 2 different providers for push notification in androidprecompiletask.xml, Please refer the below solution
If we configure the below lines in androidprecompiletask.xml then it will not work and get proper message OR content,
<replace file="${app.dir}/res/values/pushconfig.xml" token="<string name="notify_push_msg_desc_keys">" value="<string name="notify_push_msg_desc_keys">message"/>
<replace file="${app.dir}/res/values/pushconfig.xml" token="<string name="notify_push_msg_desc_keys">" value="<string name="notify_push_msg_desc_keys">content"/>
Instead of the below 2 lines to get message in both 3rd party & KMS server,
<replace file="${app.dir}/res/values/pushconfig.xml" token="<string name="notify_push_msg_desc_keys">" value="<string name="notify_push_msg_desc_keys">message"/>
<replace file="${app.dir}/res/values/pushconfig.xml" token="<string name="notify_push_msg_desc_keys">" value="<string name="notify_push_msg_desc_keys">content"/>
change to below line androidprecompiletask.xml
<replace file="${app.dir}/res/values/pushconfig.xml" token="<string name="notify_push_msg_desc_keys">" value="<string name="notify_push_msg_desc_keys">message,content"/>
It means, instead of 2 lines, replace with one line by message,content it will solve the above mentioned requirement.