Start a new topic

Problem iwth push notifications and iOS8

Hi,



I received this from a customer.



I am wondering is this is in some way related to my endpoint setup?



The code is below



Gary

---

I've been playing with the notifications a little bit on my iphone and ipad, and have found the following things:



1. Prior to upgrading my iphone to iOS 8 notifications on my iphone and ipad worked the same way

2. After upgrading my iphone to iOS 8 I receive banner alerts, but badge counts no longer display on my iphone. My ipad which is still running iOS 7 still receives both banners and badge counts. I have the same alert settings on both devices.

3. On my iphone the banner alerts now sometimes "stick" to the top of the screen. For example if I am in the mail app and a banner comes in swiping up to clear it does not work, but it does work if I'm just on the home screen.



---

`function onRequest(request, response, modules){

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

var iOSAps = { alert: request.body.message, badge: parseInt(request.body.count), 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();

});

}`

Hi Gary,

There may be a various bugs that are there in iOS 8, my apologies for the delay and thanks for reporting this. We're delving into it.
Hey, this looks like these might be issues with iOS 8--



Can you open settings -> notifications and check the settings for you app? Some of our iOS users in the office have reported their notifications getting reconfigured, and disabling/enabling them seems to work.



Hi,


I am back on this problem.

I have found that when my server sends a push my business logic runs but nothing goes to the device.

I found that when I send a push from the Engagement consols it makes it to the device.

So, that tells me there is probably something not right in my business code.

This is my code:

function onRequest(request, response, modules){
    var push = modules.push, collectionAccess = modules.collectionAccess;
    var logger = modules.logger;
    var iOSAps = { alert: request.body.message, badge: parseInt(request.body.count), 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();
    });
}

 

Hello Gary, i seem to have the exact same problem. Notifications do work from the console but business logic does not reach device although it says that it was sent.

Hi Gary & Hamad,

The sendPayload function takes a callback as a final argument (http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#push-module). It is possible that by not using this callback, the business logic function finishes execution before the notification is finished sending.

Please try passing a callback as the final argument, and calling response.complete() only once the callback returns.

 

I have tried adding a callback but it still doesn't seem to work, but i discovered that SendMessage does work in business logic with or without the callback, except sendPayload won't work at all.

 Kinvey, maybe you need to change your documentation. This link you provided says:

Push calls are asynchronous in nature. They can be invoked without a callback, but are not guarunteed to complete before continuing to the next statement. However, __once invoked they will complete the sending of the push messages, even if the business logic is terminated via response.complete, response.continue, or response.error.__

I also tried adding the call back as indicated.

No difference. 



Any update on this?

We would really like to send the badge count for which sendPayload is needed.

This used to work several months ago, which makes me think something is broken.

Gary

 

 

function onRequest(request, response, modules){
    var push = modules.push, collectionAccess = modules.collectionAccess;
    var logger = modules.logger;
    var iOSAps = { alert: request.body.message, badge: parseInt(request.body.count), 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, function(err, result) {
            response.continue();
            });
      }
    });
}

 


Login or Signup to post a comment