Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Parse Notifications on Android Device

$
0
0

Hello,

I want to show information from the notification in my Android device but I can't do it. I 've tried to parse theJson string without any result. I 've seen some forum anwers but they didn't work from me.

For example this the string that I received from the Appcelerator Studio:

{"android":{"title":"Example Title","sound":"default","alert":"Example alert","vibrate":true}}

This is my code

CloudPush.addEventListener('callback', function (evt) {
    alert("Notification received: " + evt.payload);
 
    var payload = JSON.parse(evt.payload);
 
    Ti.API.info("title: " + payload.title);
    Ti.API.info("alert: " + payload.alert);
});
On device I can see the alert with success like this:
ALERT
Notification received
{"android":{"title":"Example Title","sound":"default","alert":"Example alert","vibrate":true}}
but in the Console when I want to parse the JSON string, I have this:
[INFO] :   title: undefined
[INFO] :   alert: undefined
I 've tried in many ways with no any success.

I'm Using SDK 4.0.0 GA

Can someone help me

Thank you


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>