开发者

How can I push data to the device?

I need a way to push data to my device from my web server, how can I accomplish this? And I would love a guide to help me. I've been stuck on C2DM forever a开发者_开发知识库nd its just too much for me to handle. The guides are just all list lines after lines of code and don't explain what they do, which sucks. I'd love if you could link me to a guide that can teaches how to push data to the android device.


I agree that there isn't too much documentation about CD2M. For me, the best docs are the Google examples. You can grab them and follow the code to understand how this works. Examples are here and here.

  • For the client side (the Android app) you have 3 classes that do the heavy work. You can find them here. Use them, copy those classes to your project and then you can subclass C2DMBaseReceiver to provide your own implementation (you get a callback when you receive a message, a callback for an error, and so on). Remember to register these things in your Manifest, look at the Manifest in those examples to know how to do it.
  • The server side is a lot easier. Basically you first get an auth token from Google, and then you start sending HTTP requests that are the messages that your client will receive.
  • If you are planning on using App Engine, then you can find examples of how to implement the server in both examples.
  • If you are planning on using .NET for the server, then take a look at C2DM Sharp.
  • Else I'm sure you will find some already implemented library or some examples on how to setup the server.


Read this blog post. It references many possibilities and is probably just what you are looking for. http://tokudu.com/2010/how-to-implement-push-notifications-for-android/


Use Windows Communication Foundation (WCF) in .NET 3.5 or greater.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜