Start a new topic

Push Notification not working - sendMessage

Hello, 


I'am currently setting up push notification, i created a endpoint called by my android app. In my endpoint code, when i use  "push.broadcastMessage" or "push.broadcastPayload"  i successfully receive notification. But in my case i would like to send to specific users, so i tried to use "push.sendMessage" and "push.sendPayload", and in the two cases i don't receive notification.


Here is my forEach to get user, i've one user, but sendMessage do not work.

sendMessage callback "err" return null.


userColl.forEach(function (user) { 

         modules.logger.info('Pushing message to ' + user.Username);

         push.sendMessage(user, "People who are named are awesome!", function(err, result) {

          });

         

Do you know where is the problem?


Thanks a lot for your help.


Frank,

Copying your reply to the FD ticket on this forum post:

"

Hello Billy,


Thanks you for your answer and assistance.

Here are the answer to the questions:

 

What is the name of the app ?

- The application name is LifeSafe.

 and what is the KID of the environment where you are experiencing this problem?

- The environment is LifeSafe, in development.


Which Kinvey SDK and version number are you using?

I use the Android Kinvey SDK, version number: kinvey-android-2.10.11


TimeFrame: 

I sent push notification between this timeFrame:

NFO 04/12/17 10:20:14 am

INFO 04/12/17 10:21:08 am



Here is my code, i successfully get users but pushMessage have no effect:


function onRequest(request, response, modules){  

  var collectionAccess = modules.collectionAccess;

   var utils = modules.utils;

  var push = modules.push;

  var template = '{{name}}, the {{team}} just won!';

   var pushedMessageCount = 0;

   var userCount;

 

    collectionAccess.collection('AllUsersBase').find({_id: modules.collectionAccess.objectID(request.body.id)}, function (err, userColl) {

      if (err) {

        modules.logger.info('Query failed: '+ err);

      } else {

           userCount = userColl.length;

        userColl.forEach(function (user) {

        

          // Send the push

          modules.logger.info("Send to "+ user.Username);

          push.sendMessage(user, "test Message Push LifeSafe", function(err, result) {

                     response.continue();

            });

       

       pushedMessageCount++;

       // reduce the number of users left to push to

       userCount--;

       if (userCount <= 0){

         // We've pushed to all users, complete the request

         response.body = {"message": "Attempted to push " + pushedMessageCount + " messages."};

         response.complete(200);

       }

    });

      }

          });

 }


Thanks you very much for your help.

Best,

Franck"



Thanks,

Pranav

 

I didn't find solution on my side, i checked all the settings, endpoint code but still not working.

I can't wait to know where the problem come from.


Thanks you.

Franck

Hello Franck,


Regarding your Android Push Notification problem, you reference "TokenFirebase" in the custom endpoint "Push". Can you tell me if you are attempting to use Google Firebase to send these push notifications? When you setup your Android app to use Push Notifications did you follow the setup instructions regarding Google Cloud Messaging in the following document?


http://devcenter.kinvey.com/android/guides/push


I'm asking this because Kinvey does not yet support Firebase.


Regards,


Billy Gee

Hello Billy,


Thanks your for your answer, 


The custom endpoint i'am using is called "point" (the code is exactly the same as above in this topic). In the past yes i did used firebase to send push notification and i received it.  Right now i want to use Kinvey push notification because there is a nice "business logic".

I implemented the Kinvey client and push Receiver, I receive push notification (send via business logic) when i use the function broadcastMessage() and broadcastPayload(), but my wish is to send to specific users, and when i try to use sendMessage() or sendPayload() it doesn't work, no notification is receive and nothing seems to be sent.

I invite you to take a look at the code just above.


Thanks you very much for you help, really appreciate.

Regards



Hello Franck,


I want to check the details of your push attempts with our push service.


Please send me a direct email to billy@kinvey.com and pranav@kinvey.com for security reasons and please include the following information.

  • One or two email addresses, _id from the _messaging column, the username and anything else that will help identify the logs for the push requests that are failing to receive the push notifications when trying to send them to individuals.
  • We need fresh examples of this problem since the logs for the dates in your original post have expired. Please reproduce the problem and send the timestamp (including timezone) of the failed push attempts. Please be as accurate as possible with the timestamp.
  • The text of the message you are attempting to send.

Looking in our server logs, the only failed push attempts that I see were for a short period where you were having a business logic runtime error which you seem to have corrected. All other push attempts, including pushes to individual users, are completing successfully. This means that they were successfully sent to our push service.

I also see that you are using logging in your business logic "point" script. If you could send us the logs for the failed push requests that would be helpful as well. Again, for security reasons, include them in the email that you send to Pranav and me.

We look forward to hearing back from you.

Regards,

Billy Gee

Hello Billy,


I send you an email with all the asked informations.


Thanks you for your support.

Regards

Login or Signup to post a comment