0

I'm hoping to use Google Cloud Messaging to send messages between an Android application and a Google Chrome extension. The basic process would be:

Android app starts up...
... Android app sends initial message to Chrome extension (on PC)
... Chrome extension sends initial response message back to Android app.
... [Android app and Chrome extension continue to exchange messages]

The Android app will be using Google authentication, and the Chrome extension will of course require the user to be logged in.

Is this possible without an intermediate server? I've done some initial research, but much of the documentation seems to concentrate on using GCM between Chrome <> Server, or Android <> Server rather than between Chrome <> Android.

Thanks.

Barguast
  • 5,926
  • 9
  • 43
  • 73

1 Answers1

1

I have no experience with Chrome extensions, but as for sending GCM messages from the Android application instead of from a server, it should be possible.

Whatever code the server would normally use to contact Google servers to send GCM messages (for example the HTTP request required for sending GCM messages to Android devices) can be executed from the Android app (and probably from the Chrome extension as well, though I'm not sure about that).

The main downside to not using a server is that you don't have a central database of all the devices registered to GCM. Your Chrome extension would have to somehow know the Registration IDs of the Android devices it should send messages to and vice versa.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • The way I hope it works is that my Android app can send a message to all instances of Chrome (with the extension installed) where a user is logged in with the same Google account. Presumably here I can somehow send a response from the Chrome Extension back to the originating app [on the originating device]. – Barguast Jan 03 '14 at 14:10
  • Youre missing the basic part of knowing where (ip) is the chrome extension sitting. The extension would need to inform some central server of its ip thus you cant do it without an intermediate server. – Zig Mandel Jan 03 '14 at 15:08
  • 2
    My assumption is that the Android app would send to GCM ('I'm MyGCMApp, being used by JoeBloggs@gmail.com', and I want to send 'ABC'), and the Chrome extension would ask GCM for messages ('I'm MyGCMApp, being used by JoeBloggs@gmail.com, and I want to receive messages, and in response get the message 'ABC'. In this situation, I don't see why either the Android app or the Chrome extension need to know 'where' each other are since GCM acts as an intermediary (in a similar way to a message queue). Is this incorrect? – Barguast Jan 03 '14 at 15:19