Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Messaging over XMPP protocol (server working with PHP and XMPPHP). How does it work?

maybe you heard already about it. It was announced at the Google IO maybe one month ago. Google Cloud Messaging was only downstream (server --> phone), but now with the enhancement CCS (cloud connection server) you can send messages upstream over a persistent TCP connection thanks the XMPP protocol. I have already designed an application which works with GCM and HTTP. It uses the gcm library and the classes that are packed in there (like GCMRegistrar). This classes are now deprecated, and Google recomends to use the GoogleCloudMessaging API instead.

Everything works a little bit different now. You have the Google documentation and they explain very good, how you can design your Android App. BUT I have problems with the server, because I have never worked with XMPP before. They give a code in Python here: http://developer.android.com/google/gcm/gs.html but I have no idea over Python. So I investigated and then I found the XMPPHP library. You can then work with PHP and use the library to connect with XMPP and send/receive messages.

I have no experience working with it and it doesn´t work to me. How can I open a XMPP connection with the Google XMPP server?

I found this way to open a connection (here you work with the library):

$conn = new XMPPHP_XMPP($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);

Does anyone know which parameters do I have to pass here in order to connect with Google CCS??

I would like to know too:

How I send a message over XMPP to a device? How can I receive a message from a device??

like image 957
Estefanía Avatar asked Jun 18 '13 08:06

Estefanía


1 Answers

I run into the same problem, tried using XMPPHP, but then discovered JAXL library and switched to it. See unable to connect to Google Cloud Connection Server. JAXL allows you to watch what it sends, using special debug mode 'log_level' => JAXL_DEBUG. Then I saw that Google sends me this:

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><temporary-auth-failure/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Project 1945693724760 not whitelisted.</text></failure>

That was the reason I couldn't send any notifications. You should first register for CCS here: https://services.google.com/fb/forms/gcm/.

like image 180
Fancy John Avatar answered Nov 07 '22 20:11

Fancy John