Start a new topic

Android Push


This seems to work, sort of:

However, what can I put in androidPayload to cause it to play a sound and show a badge count like the SMS does?

function onRequest(request, response, modules){'Starting=' + request.body.KinveyID);

var push = modules.push, collectionAccess = modules.collectionAccess;

var iOSAps = { alert: request.body.message, badge: request.body.count, sound: "default" };

var iOSExtras = '';

var androidPayload = {message: request.body.message };

collectionAccess.collection('user').findOne({ "_id": collectionAccess.objectID(request.body.KinveyID) }, function(err, user) {

if (user)

{'Pushing message to ' + request.body.KinveyID);

push.sendPayload(user, iOSAps, iOSExtras, androidPayload);





Hey Gary, I'm sorry for the delay on this. Our library owner is away at Google i/o this week.
Oh, I see I have a typo in my question. It should read.

"However, what can I put in androidPayload to cause it to play a sound and show a badge count like the APS does?"

The problem with the delay is I have two clients waiting for this to be implemented.
Hi Gary,

Google Cloud Messaging (GCM) doens't work quite the same way as the Apple Push Notification Service (APNS). With GCM, you can send whatever payload you want and then you manage what you want to do in your native client code.

So for example, to play a sound:


try {

Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);;

} catch (Exception e) {




You can pass different values in the payload and play the appropriate sound based on what you pass, but the attribute you pass is up to you and not defined by Android.
But what if the app isn't running at the time of the push?
Maybe I should mention that the code runs fine when the app is running. I get the Push Received event and I then do a local notification and play a sound and I pull the server.

But when the app is not running the message in the push is displayed in the notification drawer, no sound, and I don't get the push received event UNTIL someone taps the notification. Which kind of defeats the whole point of a push, to alert someone when their phone is in their pocket or sitting on the desk.
Can you provide the code for your class that extends KinveyGCMService, your broadcast receiver, and your application manifest section that contains the receiver entry?

I'm using Rad Studio XE6. PushEvents is their Push object and uses their Kinvey provider.

This is the PushRecived event handler:

procedure TNotifications.PushEvents1PushReceived(Sender: TObject; const AData: TPushData);


ChirpMaxDB.Log('Doing PushEvents1PushReceived');

ChirpMaxDB.fUpdateNow := 1;

This is the manifest. I've been thinking there might be something wrong with it.

The parts related to Push are from their tutorial.





android:label="Williamsburg Live 411"







android:label="Williamsburg Live 411"


android:value="ChirpMax" />

Hi Gary,

The RAD Studio client library was independently developed by Embarcadero, so I don't have a whole lot of insight into its internals. The code that wakes up to play a sound, etc., is purely client side, so you may have to contact Embarcadero to resolve why it isn't specifically waking up when the app is not running. If you need further help with this, let me know.

Can I take it that you don't see any problems with the manifest file?
Not that I can see...

Ok, thanks. Still it's not working like it should. I posed a question on the Embarcadero forums and still no answer.
Hi Gary,

I am trying to get this working in delphi XE7.

Did you have any sucess ?

Do you have a link to the delphi forums where you posted.

Login or Signup to post a comment