iOS standalone push notifications not working

#1

Hey,

I’ve got a problem with my push notifications on my standalone iOS app. I don’t understand:

  • it works perfectly on my Android standalone app.

  • it works on both iOS / Android when I test it with Expo before deploying it : I get the token, save it to my database, detect perfectly new notifications with Notifications.addListener() …

My app slug is : tiebreakprod .

When I do : exp fetch:ios:certs , it works. My certs are up. I also checked my server after my httpRequest :

Parse.Cloud.httpRequest({
method: ‘POST’,
url:‘https://exp.host/--/api/v2/push/send’,
headers: {
Accept: ‘application/json’,
‘Accept-encoding’: ‘gzip, deflate’,
‘Content-Type’: ‘application/json’,
},
body: JSON.stringify({
to: token,
sound: ‘default’,
title: sender,
body: message,
badge: badgeNumberIncrease,
priority: ‘high’,
data: {“title”:sender, “body”:message}
})
}).then(function(httpResponse) {
console.log('Request succeeded ’ + httpResponse.text);
}, function(httpResponse) {
console.error('Request failed with response code ’ + httpResponse.status);
});

The response is ‘Request succeeded’.

I’m using SDK 25. I’m a bit lost. Can you help me ?

Big thanks,

Alexis

0 Likes

#2

The HTTP request can succeed even though there was an API error, since the API is at a different abstraction layer than HTTP. Have you inspected the API response to see if there are API errors, as covered in the documentation?

0 Likes

#3

Do you mean using Notifications.addListener() ? Yes I use it to create a dropdown alert on iOS.

The response I get is :

Object {
“data”: Object {
“body”: “vous a envoyé un message.”,
“title”: “Sylvie”,
},
“origin”: “received”,
“remote”: true,
}

This is on my prod version (slug: tiebreakprod). It works fine when I’m using Expo XDE and my iOS devices. But it does not work on my iOS standalone app … it works on my Android standalone app though. I’m lost !

0 Likes

#4

Ok I got the real pb :
{
“data”: {
“status”: “error”,
“message”: “The certificate to connect to the Apple Push Notification service for this app does not match the environment for your app (development). Expo needs valid certificates for the correct environment in order to deliver notifications to APNs.”,
“details”: {
“error”: “InvalidCredentials”
}
}
}

Was using HttpRequest on Parse server, and it did not show the API error message. Had to use Postman.app which is great !

I uploaded my own iOS certs (wrongly I guess) and that is what caused the error. I did not know it was possible to let Expo run the app certs if you had already created your iOS certs previously. And it is !

So I used this command : “exp build:ios -c --revoke-apple-dist-certs --revoke-apple-push-certs” (found on this forum, unfortunately not in the docs!)

It worked for me ! Hope it can help someone one day … :stuck_out_tongue:

1 Like

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

0 Likes