callback node js

Pushsafer make it easy and safe to get push-notifications in real time on your Android or Windows mobile device, iPhone, iPad and Desktop!

Mit Pushsafer kann man in Echtzeit, einfach und sicher, Push-Benachrichtigungen auf sein iPhone, iPad, Android oder Windows Gerät sowie auf den Desktop senden lassen!

======================
Google Play
App Store
Windows Store
Homepage
ubicar
Posts: 4
Joined: 29. Apr 2022, 16:00

callback node js

Postby ubicar » 29. Apr 2022, 16:09

First of all congratulations for this powerful service & app!

I have setup the callback url to our node js backend service. After a send notification the url is called but with empty data:

/pushsafer callback req.body: {}
/pushsafer callback req.params: {}
/pushsafer callback req.query: {}

while I was expecting req.body.json to be like:

{
"status":1,
"success":"message transmitted",
"available":1823,
"message_ids":"1324312:118,1324313:324"
}

Am I missing something?

Thank you.

Regards.
Denis

User avatar
admin
Site Admin
Posts: 944
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: callback node js

Postby admin » 29. Apr 2022, 19:00

Hi Denis,

the data you will find in POST parameter json

https://www.pushsafer.com/en/pushapi#api-callback

Kevin
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

ubicar
Posts: 4
Joined: 29. Apr 2022, 16:00

Re: callback node js

Postby ubicar » 3. May 2022, 09:24

Thank you for your message Kevin.

Unfortunately, it looks like there is no json parameter in the POST request. (req.body is empty)

Best regards.
Denis

User avatar
admin
Site Admin
Posts: 944
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: callback node js

Postby admin » 3. May 2022, 09:51

Just tested (with PHP), works as it should

Response

Code: Select all

{"status":1,"success":"message transmitted","available":22159,"message_ids":"22369782:119"}
Kevin
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

ubicar
Posts: 4
Joined: 29. Apr 2022, 16:00

Re: callback node js

Postby ubicar » 3. May 2022, 10:17

For information, as the request body is a multipart message, bodyParser package does not handle the post parameter. multer package is needed.

var multer = require('multer');
var forms = multer();
app.use(forms.array());

finally, in the post route, the req.body is fine:

/pushsafer callback req.body: {"json":"{"status":1,"success":"message transmitted","available":982,"message_ids":"22371903:52962"}"}

best regards.
Denis

User avatar
admin
Site Admin
Posts: 944
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: callback node js

Postby admin » 3. May 2022, 19:05

thanks for sharing!

Kevin
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10


Who is online

Users browsing this forum: Antoniotme, Google [Bot], Michailvju, Ronaldsype and 16 guests