`UnknownError` when sending `SilentNotification`
rr-codes opened this issue · comments
Richard Robinson commented
The error I receive is
{
"reason": "UnknownError",
"notification": {
"_deviceToken": "<OMITTED>",
"_options": {
"contentAvailable": true,
"pushType": "background",
"priority": 5
}
}
}
My code is
const sn = new SilentNotification(deviceToken)
try {
await apnsClient.send(sn)
res.sendStatus(200);
} catch (e) {
const message = `Error sending notification: ${JSON.stringify(e)}`
console.log(message)
res.status(500).send(message)
}
where apnsClient
is configured as
export const apnsClient = new APNS({
team: process.env.APNS_ISS,
keyId: process.env.APNS_KID,
signingKey: process.env.APNS_AUTH_KEY,
host: process.env.APNS_SERVER
})
and process.env.APNS_SERVER
is https://api.sandbox.push.apple.com/
.
I'm using node v14.10.1.
Andrew Barba commented
I think it's the way you defined APNS_SERVER
. Try setting it to api.sandbox.push.apple.com
. Notice no https or trailing slash
Richard Robinson commented
@AndrewBarba Yup, that fixed it; thanks!!