Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use GCM in Android without a dedicated server?

I am conceptualizing an Android app that sends data from one device to another (like a picture message), but because I do not have a server, I am looking into other ways of messaging. Google Cloud Messaging (GCM) seems like a good choice, since its made for Android, and is free to use, but it still requires a server to use. Is there a way around this requirement- such as running the GCM server on the app itself? Or is there a better approach to serverless messaging on Android?

like image 324
Phil Avatar asked Nov 22 '12 19:11

Phil


2 Answers

Yes you can - it's possible to send the same messages from a device that would be sent from a server. However, this has the following problems:

  1. You're putting your API key in your app, so somebody could decompile your APK to get it.
  2. Your users would need some way to share their GCM registration IDs with each other. If two users had both their IDs expire at the same time, there would be no way to share them again.

Really, building your app and hosting it on AppEngine would take about an hour to write, and cost less than $10 a month, even for a ton of users.

For a dead-simple messaging server example written in Java, check out the server backing one of my apps:

https://github.com/charlesmunger/touch-to-text-server.git

like image 87
Charles Munger Avatar answered Oct 19 '22 10:10

Charles Munger


I think that will be hard to do what you want effectively without a server but you can check out Parse's SDK. It is free to try and free up to a certain monthly limit.

The docs. You may want to read "Sending Pushes to Channels" and "Using Advanced Targeting".

like image 40
irwinb Avatar answered Oct 19 '22 08:10

irwinb