Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialaakarshrestha
6,509 PointsHow to push two different types of notifications using Google Cloud Messaging service?
In my app, i am able to implement the Google Cloud Messaging service and push notification works fine. But the push notification is only for one type of notification such as when the text message is sent. But I want to implement another push notification when the user sends the friend request.
I tried implement a service extending GcmListenerService but still only one push notification works.
Any help is highly appreciated!
Happy coding!
2 Answers
aakarshrestha
6,509 PointsHi Mahmoud,
I hope you are enjoying your android development. I had the problem sending out different types of notifications. I am not sure if you are able to send the first notification but i hope if you are able to.
I am using php as my backend. If you have GCM working on your web server then you need to change the data value in the web server file.
Below is the example:
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => array($gcm_token),
'data' => array("name" => $username), //added senderName in the array
);
So for every different kind of notifications, you need to change the key i.e. "name". Then in android you need to read the key and that will send a notification.
Hope it helps you understand. If you don't mind, you can share you code and i will help.
Happy coding!
aakarshrestha
6,509 PointsNevermind... I have solved the issue I was trying to solve. It is working just as intended.
If anyone is having the save problem, please write the comment and I will help.
Happy coding!
Mahmoud Amin
Courses Plus Student 6,269 PointsHow could you solve it!!!!.....Please help