Start a new topic

Android Push

Hi,



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){

modules.logger.info('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)

{

modules.logger.info('Pushing message to ' + request.body.KinveyID);

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

}

response.complete();

});



modules.logger.info('Ending');

}

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.



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

Ok.



Can I take it that you don't see any problems with the manifest file?
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.
Hi,



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);

begin

ChirpMaxDB.Log('Doing PushEvents1PushReceived');

ChirpMaxDB.fUpdateNow := 1;
end;



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



The parts related to Push are from their tutorial.








package="com.chirptest.max.live"

android:versionCode="9"

android:versionName="2.0.0">




















































android:restoreAnyVersion="False"

android:label="Williamsburg Live 411"

android:installLocation="preferExternal"

android:debuggable="True"

android:largeHeap="False"

android:icon="@drawable/ic_launcher"

android:theme="@android:style/Theme.NoTitleBar"

android:hardwareAccelerated="true">




android:label="Williamsburg Live 411"

android:configChanges="orientation|keyboardHidden">




android:value="ChirpMax" />

































Can you provide the code for your class that extends KinveyGCMService, your broadcast receiver, and your application manifest section that contains the receiver entry?
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.
But what if the app isn't running at the time of the push?
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);

r.play();

} catch (Exception e) {

e.printStackTrace();

}

```



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.
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.
Hey Gary, I'm sorry for the delay on this. Our library owner is away at Google i/o this week.
Login or Signup to post a comment