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

1

7

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??

Chicken answered 18/6, 2013 at 8:41 Comment(3)
$conn = new XMPPHP_XMPP('gcm.googleapis.com', '5235', '<your_GCM_Sender_Id>@gcm.googleapis.com', 'apikey', '', $server, 'true', 'info');Reitman
I think it works now, should I let this connection open? Do you know how can I send a message to the device to test that everything works correctly? I have the Android App ready with the Broadcast receiverMassimo
can you provide me the code for the latest gcm server code?Feline
R
2

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/.

Remanent answered 4/10, 2013 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.