Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using XMPP for push user notifications on Android - any way to target these so they don't go to Google Talk etc

I want to use XMPP to push data to my client which would translate to a notification for the user, and plan on using their google-id for login to my application. The way I understand XMPP is that its a simple message that goes directly to the adress, but I want the client to get it as instructions and turn it into gamestate information.

It would be very frustrating for a user to get a bunch of command tuples or hex garbage in their google chat! Am I misunderstanding the way this all works?

like image 707
Hortinstein Avatar asked Mar 18 '10 19:03

Hortinstein


People also ask

Do push notifications work on Android emulator?

You can also test push notifications in the Android emulator. Like the iOS Simulator, it can register for notifications and display them.

How do I send silent push notifications on Android?

There are two ways users can receive silent push notifications on Android. Users can long press on a notification to get an option to display notifications silently. Users can also enable silent notifications by heading to Settings > App & Notifications > Search for app and choose> Notifications, and turn it off.


2 Answers

JIDs (Jabber/XMPP IDs and therefore Google Talk IDs) have several forms.

First is a "bare JID", e.g.: [email protected]
Secondly is a "full JID", e.g.: [email protected]/xyz123, where xyz123 is called the resource.

One user can be logged into their XMPP account from multiple clients simultaneously, so long as each client uses a unique resource. With Google Talk, usually the server allocates the resource.

When you talk to someone on XMPP normally you address messages using their bare JID — you don't care about which client the message gets delivered to; that person's server directs it to the appropriate client(s) based on their availability etc.

But you can also address a message directly to a full JID. This is what you want to do, so that only [email protected]/my-game-some-unique-ID receives your game-specific messages.

Whether the Google App Engine API gives you this flexibility, I have no idea :)


An alternative — again, if GAE allows this — is to send a different message type.
XMPP is eXtensible, meaning that you don't have to send a plain old <message/> stanza to the end user; you can stick a specialised payload inside there like a <game/> child stanza and, because regular IM clients don't know how to parse your <game/> stanzas, they show nothing to the user. Only your game client will parse and understand this info.

like image 128
Christopher Orr Avatar answered Oct 04 '22 11:10

Christopher Orr


“Xtify has an out of the box solution that runs a variant of XMPP. You can then use their webservice to push notifications and custom data and intents to the device and your app. I've been using there more standard solution (platform for push and managment), but the push API works and is free.

like image 24
peter Avatar answered Oct 04 '22 11:10

peter