I'm new to Android so I'm looking for the best approach to send text/data
from a server
(webservice) to one specific android device
at a time (each time to another user). The steps are:
The main problem for me is to define how do I send a data to the specific user - by ID\\username
, device ID, other? I tried to practice GCM but it seems not exactly what I'm looking for because I'm planning to use the same server to send data not only to android devices but to iphone/windows as well. Thank you.
For android, you should use GCM. For other platforms, they should have their Push Messaging api on its own.
So, when a phone registers with GCM, you will get a handle which you will communicate to your server. When you store this handle in a database or something, also keep the kind of phone (Android, iOS, etc).
When you want to notify the user, check which kind of store it is and implement different protocols for different platforms.
There might be some library that abstracts this away too
but I don't know any
.
Edit: I've found some
You may want to check Urban Ship (commercial), PushSharp a server-side library to let you send push notifications to many platforms or yet and alternative: StackMob . Just google for more options if neither please you.
There is no way to contact devices directly from your server
Your only kind of push solution is cloud messaging. Alternatively you can implement folowing schema:
If you like to have "offline"-mode, you may consider message expiration ( say, your poll interwal is 5 minutes so expire all messages not retrieved inside 10 minutes )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.