简体   繁体   English

Google Cloud Messaging和MySQL数据库

[英]Google Cloud Messaging and MySQL database

I want to use Google Cloud Messaging for my app for both upstream and downstream use, using xmpp. 我想使用xmpp将Google Cloud Messaging用于我的应用程序以供上游和下游使用。 However I am wondering how I can select and input data to and from my MySQL database to be sent over the GCM network. 但是,我想知道如何选择和输入MySQL数据库中的数据,以及如何通过GCM网络发送数据。

Can I use PHP with GCM or do I have to use Java or Python? 我可以在GCM中使用PHP,还是必须使用Java或Python?

GCM is used for sending messages FROM server TO your android application. GCM用于从服务器向Android应用程序发送消息。 Also a GCM message can only carry a maximum of 4KB Only. 此外,GCM消息最多只能携带4KB。 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); 因此,我认为直接从应用程序将数据发送到MySQL数据库(如果要使其异步,请查看Android同步适配器); 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. 为了将数据从服务器异步发送到您的应用程序,请使用GCM向您的应用程序发送ping(可以是任何短消息),这样您的应用程序就可以执行正常的http请求-响应过程,以从MySQL获取数据。

For more information of Sync Adapters: http://developer.android.com/training/sync-adapters/index.html 有关同步适配器的更多信息: 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 有关使用PHP的简单GCM的教程, 请访问http : //www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

There are XMPP libraries for PHP. 有用于PHP的XMPP库。 See https://code.google.com/p/xmpphp/ for example. 例如,请参见https://code.google.com/p/xmpphp/ So, PHP is possible, however i would really like to hear what is a recommended approach, as im going to implement it too. 因此,PHP是可能的,但是我真的很想听听什么是推荐的方法,因为我也要实现它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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