Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device to Device push notification using android gcm without third party server

We are planning to wirte a messaging/chat kind applicaiton on Android.We are planning to use GCM to exchange messages.The traditional way is to have a Application Server to store all the gcmid of the users and if user1 wants to send message to user2,

1.The user1 send the message to Application server with payload which contains message and receipent id i.e user2 2.The application server retrieves the gcmid of user2 and call sender.send(regid2 , message) 3.User2 receives the message.

I see it is just a REST API Call to https://android.googleapis.com/gcm/send.

So if somhow user1 has the gcmid of user2 why can't we directly call the gcm API from user1 device to reduce the load on server and cost of operations on server.Pls advise me on this.

Note:We are not planning to use Upstreaming

like image 313
user2653234 Avatar asked Nov 10 '22 05:11

user2653234


1 Answers

i did the same using Device_To_Device_Messaging_Using_Google_Cloud_Messaging_GCM_-_Android_Example tutorial. this tut is having complate sever as well as client code using gcm. go through it,will help you to achieve what you want.

like image 159
Pankaj Arora Avatar answered Nov 15 '22 07:11

Pankaj Arora