Start a new topic

iOS Push

Hi,



This is my endpoint:



function onRequest(request, response, modules){

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

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

var iOSExtras = '';

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

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

if (user)

{

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

}

response.complete();

});

}



It used to play a sound.



Now it doesn't and the badge doesn't change to 10.



Any ideas why it's not working now?

Hi Gary,

We end up seeing a lot of issues like this that are resolved by reissuing the certificate. Give that a shot and see if that fixes it.
Hmm, both certificates are less then a month old, one was just issued last week.



Could this be an issue with Urban Airship?
It could be. If it's Urban Airship, resetting the device token often fixes the problem. Here's a thread similar to that: https://support.kinvey.com/discussion/comment/201904858#Comment_201904858
Caroline,



That thread doesn't say HOW to reset the device token.



Would it be something, like unregistering the device and then re-registering.
Hi, I tried un-registering and re-registering the device token. I saw the token go away in the user record. Still no sound. I receive, that is IOS receives, the push message, but no sound, and no badge. It shows up in the notification area.
Did you also reissue the certificate? Just trying to rule that out.
Not yet, I'm removing some multiple registrations for another user.
Ok, I reloaded the two SSL certificates I had and still not sounds. I tried sending to each of the two apps. I got the message, but no sound. And no badge.



Should I try regenerating the certificates?



I didn't want to do that during the day, I thought that would kill the functionality that is there. We are in semi production for both apps.



I can try that tonight when things can propagate before the morning.
Maybe I should mention that I asked some of my testers last night and they said they were getting sound and badges.



Wouldn't that indicate there is nothing wrong with the certificate?



Also, I started wondering if sound was working on my iPad so I went to iTunes and got sound.



So now I'm a but perplexed.



I also checked the Notification Center settings and sound is turned on for both of my Apps.
Regarding the badges, I found my code was wrong.



This:



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



Should be this:



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



When I did this the badge started showing up.



So in my end point I changed it to this:



`var iOSAps = { alert: request.body.message, badge: parseInt(request.body.count), sound: "default.wav" };`
Good catch, Gary! Glad it's working now.
Login or Signup to post a comment