Please provide the following:
- SDK Version: 39
- ios
Hi all. We are trying to migrate from Expo push service to APN. But we’ve faced a problem.
We are receiving device push token via getDevicePushTokenAsync() and made a server with simple code.
let apn = require('node-apn');
let options = {
token: {
key: "./AuthKey.p8",
keyId: "our_key_id",
teamId: "our_team_id"
},
// cert: "./apns-dev-cert.pem",
// key: "./apns-dev-key-noenc.pem",
production: true//false not matter
};
let deviceToken = "1075eb4748******492ea9d1e39f72699551eff77******";
var apnProvider = new apn.Provider(options);
var note = new apn.Notification();
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 3;
note.alert = "\uD83D\uDCE7 \u2709 You have a new message";
note.payload = {'messageFrom': 'John Appleseed'};
note.topic = "ru.project.site";
apnProvider.send(note, deviceToken).then( (result) => {
console.log(result.failed);
});
When its in production we are getting:
- status: ‘400’,
- response: { reason: ‘DeviceTokenNotForTopic’ }
When its in development mode: - status: ‘400’,
- response: { reason: ‘BadDeviceToken’ }
We made all as docs required, but still getting that error.
We were trying to set our push key via expo credentials manager - no effect. And on the server side we tried to change from key to certificate options - same effect.
What we are doing wrong? Thanks.