简体   繁体   中英

Google Cloud Messaging and MySQL database

I want to use Google Cloud Messaging for my app for both upstream and downstream use, using xmpp. However I am wondering how I can select and input data to and from my MySQL database to be sent over the GCM network.

Can I use PHP with GCM or do I have to use Java or Python?

GCM is used for sending messages FROM server TO your android application. Also a GCM message can only carry a maximum of 4KB Only. So in my opinion, send data to your MySQL db directly from the app (If you want to make this asynchronous, look into Android Sync Adapter); and for sending data from server to your application asynchronously, send a ping to your app using GCM (it can be any short message), so your app can undergo a normal http request-response procedure to get the data from MySQL.

For more information of Sync Adapters: http://developer.android.com/training/sync-adapters/index.html

And for a tutorial on a simple GCM using PHP: http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

There are XMPP libraries for PHP. See https://code.google.com/p/xmpphp/ for example. So, PHP is possible, however i would really like to hear what is a recommended approach, as im going to implement it too.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM