push notification error 8
See original GitHub issueDoes this error mean I have set up my cert and key pem files incorrectly? I get the following log:
Connected Notification transmitted to:98d86f0605e899fea311c82b13bc774c8ca58ba1208333ca2403fdc0d4ecbc7f Notification caused error: 8 for device { token: <Buffer 98 d8 6f 06 05 e8 99 fe a3 11 c8 2b 13 bc 77 4c 8c a5 8b a1 20 83 33 ca 24 03 fd c0 d4 ec bc 7f> } { encoding: ‘utf8’, payload: { aps: { alert: ‘Hello, from node-apn! You are number: 0’ } }, expiry: 0, identifier: 0, priority: 10, retryLimit: -1, device: undefined, alert: ‘Hello, from node-apn! You are number: 0’, badge: ‘0’, sound: undefined, newsstandAvailable: undefined, contentAvailable: undefined, mdm: undefined, compiled: true, truncateAtWordEnd: false, urlArgs: undefined, compiledPayload: ‘{“aps”:{“alert”:“Hello, from node-apn! You are number: 0”}}’ } Disconnected from APNS
I copied your example code:
var apn = require(‘apn’); var tokens = [“my token with no spaces”];
if(tokens[0] == “<insert token here>”) { console.log(“Please set token to a valid device token for the push notification service”); process.exit(); }
// Create a connection to the service using mostly default parameters. var service = new apn.connection({ gateway:‘gateway.sandbox.push.apple.com’ });
service.on(‘connected’, function() { console.log(“Connected”); });
service.on(‘transmitted’, function(notification, device) { console.log(“Notification transmitted to:” + device.token.toString(‘hex’)); });
service.on(‘transmissionError’, function(errCode, notification, device) { console.error("Notification caused error: " + errCode + " for device ", device, notification); });
service.on(‘timeout’, function () { console.log(“Connection Timeout”); });
service.on(‘disconnected’, function() { console.log(“Disconnected from APNS”); });
service.on(‘socketError’, console.error);
// If you have a list of devices for which you want to send a customised notification you can create one and send it to and individual device. function pushSomeNotifications() { for (var i in tokens) { var note = new apn.notification(); note.setAlertText("Hello, from node-apn! You are number: " + i); note.badge = i;
service.pushNotification(note, tokens[i]);
}
}
pushSomeNotifications();
Issue Analytics
- State:
- Created 9 years ago
- Comments:12
For anyone else googling and stumbling on to this issue, check to make sure that the cert which you generated the pem file matches the app bundle id of the app you are running. Also make sure that in xcode, you have push notifications turned on in your project’s target capabilities!!!
Solved Notification payload use for app run or background for right way Push Notifiaction