Using the JavaScript SDK can not send push notifications

0 votes

Hi,

I try to send a push from the Web using JavaScript.

Push to send using the "sendPushMessageToAll" function gives well-received.

However, using a push "send Push Message To User" function does not arrive.

What's the problem in the source below?

Answers please.

 

  //username PUSH
  function Push_Username(){
   var apiKey = '3e3a8b7f8c0d........................................';
   var secretKey = '5e7b23f261d6.....................................';
   var userName = "hj",
   message  = "username PUSH By JS",
   result ; 
   App42.initialize(apiKey, secretKey);
   var pushNotificationService  = new App42Push();
   pushNotificationService.sendPushMessageToUser(userName, message, { 
    success: function(object)
    { 
     var pushNotification = JSON.parse(object); 
     result = pushNotification.app42.response.push;
     console.log("UserName is : " + result.userName);
     console.log("Message is : " + result.message) 
     console.log("Expiry is : " + result.expiry) 
    }, 
    error: function(error) { 
    } 
   });
  }

 

 

 

asked Mar 25, 2016 in JavaScript by freeglass (10 points)

1 Answer

0 votes
Hi, 
 
Could you please share the push logs which you are getting inside AppHQ Management Console at the time when you are sending  push to user. It will help us to provide better support to you. 
To see push logs inside AppHQ Management Console, click on Unified Notification - > Push -> Logs. 
 
Regards,
Himanshu Sharma
answered Mar 25, 2016 by hs00105 (2,005 points)
Hi,
"Send Push Message To User" function is not left on the log.
But other functions are in the log.
Do you have a problem with my source?

App42_PushNotification    INFO    2016-03-25T00:33:25Z    Message sent successfully to Android Devices : No. of devices : 1
Hi,
I found the problem.
I sent the message to push "Send Push Message To User" function arrived at dawn the next day.
But I do not know why push messages coming the next day.
Why is that?
Do you have a problem with my source?

And "sendMessage To Device" function is an error in the JavaScript.

POST https://api.shephertz.com/cloud/1.0/push/sendMessageToDevice/hj?version=1.0 404 (Not Found)
test.html:123 {"app42Fault":{"httpErrorCode":404,"appErrorCode":1709,"message":"NOT FOUND","details":"User by the name 'hj' device token 'device / JS - HJ' does not registered."}}

And I tried to also test using PHP.

The result is a success messages from PHP.

However, the message does not arrive.

"App 42" of the push is there a serious problem to the stability of the message sent?

If this does not solve the problem, we do not write the "App42".
Hi FreeGlass,

The exception message which you have shared occurs when the user by the "hj" does not have any device register with us. So could you please verify the same and let me know if you still face any issue.

P.S Logs does not show in AppHQ in case you have not configured Push Settings. Please have a look at this (http://api.shephertz.com/tutorial/Push-Notification-Android/?index=pn-android) link for more details and let me know if you still face the issue. I will be happy to help you!!!

Regards
Himanshu Sharma
Hi,
ID "hj" device are registered.
The problem is that the device is registered, even though it occurs.
This is my app name "GnBNote".
If you do not have a problem when you have a test, do you give me a sample?
I need a sample well in PHP or Javascript.
Thanks
Hi FreeGlass,

It seems like you are trying to send message to wrong device token which is not registered with us. We have checked from the backend for you app and we are able see that you have device token start with this  (APA91bFbPauzbJN48BKGNHSux4fv-0A-b7-) for "hj" user.  So please send correct device token at the time of sending push or use sendPushMessage to user api (http://api.shephertz.com/app42-docs/push-notification-service/#send-push-message-to-user). If you still get any exception then please let me know.

I will be happy to help you.

Regards,
Himanshu Sharma
Hi,
I am facing the same issue.
I am trying to send push notification from PHP, App42 respond normally but unable to receive message on device.
Although message received properly to same user when try to send from App HQ interface and also from java code*.
can you share the response which you are getting at the time of sending push. Also, Can you confirm that you having delay or you are not able to receive the message.

regards,
Himanshu Sharma
I got following response, it is about 7 hours and i didn't receive the notification.  
Message is :TestExpiry is :2016-03-31T6:54:35.503ZUserName is :cf01afbb-49a3-423f-b89d-c3c2d30e3194

Regards,
Zulqarnain
Hi,

We believe your query has been resolved over the email, if you still face any issue, then let us know. We will be happy to help you!!!

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...