I'm trying to setup push notifications on my local parse server. I get this error when trying to send a push:
parse-server-push-adapter APNS cannot find vaild connection for 9a86...21
(The error repeats for every installation device token.)
Any ideas?
My server code:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '',
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
liveQuery: {
classNames: ["Mission"]
},
filesAdapter: new S3Adapter(
process.env.S3_ACCESS_KEY || '',
process.env.S3_SECRET_KEY || '',
process.env.S3_BUCKET || '',
{directAccess: true}
),
push: {
ios: {
pfx: 'certificates/development.p12',
bundleId: 'co.example.myApp',
production: false // Dev
}
}
});
I'm pushing from my cloud code:
var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.containedIn('user', specificUser);
Parse.Push.send({
where: installationQuery,
data: {
"alert": "Loren ipsum ",
"id": MyCustomId
}
}, { useMasterKey: true }, {
success: function() {
console.log("Push was successful!");
},
error: function(error) {
console.error(error);
}
});
What cause the error is that you have a device in the installation table that matched the filter on the push
request that is no longer registered in Apple for your app. When Apple receives a request for a notification to a device that is no longer registered to your application it returns that message to indicate you should take some action if it continues to happen.
In my case I have four devices registered in the installation table that matched my push
filter and two of those devices are no longer registered in Apple for my app so every time I push it get that error for each of invalid installations.
I'm not sure why it happens but I've seen the following scenarios that causes a new installation record to be created that invalidates the prior installation. It seems like something the parse service could monitor and take action for after getting so many errors for that device token with no successful pushes between errors.
deviceToken
value is changed.To resolve the errors you simply need to remove the installation that matches the deviceToken
in the error message
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With