i have this code in (push notification payload) my application :
var payload = {"message":"Bundle[{id=0, title=This is a test
notification, android.support.content.wakelockid=3,
collapse_key=push, from=93469011985}]","inBackground":0};
And i want to access to the "id" and "title" properties in this JSON. How can i do this ? thx in advance :)
I have tried to do things like this :
console.log (payload.message['id'])
But it does not work.
var id = payload.message.substring(payload.message.indexOf("id=") + 3, payload.message.indexOf(",", payload.message.indexOf("id=")));
var title = payload.message.substring(payload.message.indexOf("title=") + 6, payload.message.indexOf(",", payload.message.indexOf("title=")));
console.log(id, title);//prints 0 This is a test notification
Warning This code will fail if you have ,
in the middle of the title.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments