{"action":"created","issue":{"url":"https://api.github.com/repos/argon/node-apn/issues/268","labels_url":"https://api.github.com/repos/argon/node-apn/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/argon/node-apn/issues/268/comments","events_url":"https://api.github.com/repos/argon/node-apn/issues/268/events","html_url":"https://github.com/argon/node-apn/issues/268","id":77696270,"number":268,"title":"Sending Push Notifications does not work reliably","user":{"login":"akohout","id":759340,"avatar_url":"https://avatars.githubusercontent.com/u/759340?v=3","gravatar_id":"","url":"https://api.github.com/users/akohout","html_url":"https://github.com/akohout","followers_url":"https://api.github.com/users/akohout/followers","following_url":"https://api.github.com/users/akohout/following{/other_user}","gists_url":"https://api.github.com/users/akohout/gists{/gist_id}","starred_url":"https://api.github.com/users/akohout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akohout/subscriptions","organizations_url":"https://api.github.com/users/akohout/orgs","repos_url":"https://api.github.com/users/akohout/repos","events_url":"https://api.github.com/users/akohout/events{/privacy}","received_events_url":"https://api.github.com/users/akohout/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-18T15:21:24Z","updated_at":"2015-05-19T08:20:43Z","closed_at":null,"body":"I'm using node-apn in production for our app. In case certain events take place, we'll inform our users about that event via push notification. In addition, they see a message  next time they open the app. So they know when they haven't received a push although they should have. And it seems to happen a lot of times that push notifications do not receive - although there is no error message.\r\n\r\nHave any one of you had similar problems with that? \r\n\r\nWhen starting our API, we do the following to initialize the APN connection:\r\n\r\n```\r\nvar apnOptions = {\r\n    cert: config.push.certFile,\r\n    key: config.push.keyFile,\r\n    production: config.push.production\r\n};\r\nvar apnConn = new apn.Connection(apnOptions);\r\n\r\napnConn.on('transmissionError', function(type, notification, device) {\r\n    var error = underscore.invert(apn.Errors)[type];\r\n    logger.error('Error on sending iOS push notifications: ' + error, device);\r\n});\r\n```\r\n\r\nTo later send a push we do:\r\n```\r\nvar tokens = recipients.map(function (user) {\r\n        return user.push_token;\r\n    });\r\n    if (!tokens.length) {\r\n        return;\r\n    }\r\n    var notification = new apn.Notification();\r\n    notification.expiry = Math.floor(Date.now() / 1000) + config.push.expiresSeconds; // set to 1 day\r\n    notification.badge = 1;\r\n    notification.sound = 'default';\r\n    notification.alert = message;\r\n    apnConn.pushNotification(notification, tokens);\r\n```\r\n\r\nI know that Apple does not give feedback whether it was delivered or not, but I hope that we're doing something wrong and the reliability can be improved."},"comment":{"url":"https://api.github.com/repos/argon/node-apn/issues/comments/103395431","html_url":"https://github.com/argon/node-apn/issues/268#issuecomment-103395431","issue_url":"https://api.github.com/repos/argon/node-apn/issues/268","id":103395431,"user":{"login":"argon","id":107645,"avatar_url":"https://avatars.githubusercontent.com/u/107645?v=3","gravatar_id":"","url":"https://api.github.com/users/argon","html_url":"https://github.com/argon","followers_url":"https://api.github.com/users/argon/followers","following_url":"https://api.github.com/users/argon/following{/other_user}","gists_url":"https://api.github.com/users/argon/gists{/gist_id}","starred_url":"https://api.github.com/users/argon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/argon/subscriptions","organizations_url":"https://api.github.com/users/argon/orgs","repos_url":"https://api.github.com/users/argon/repos","events_url":"https://api.github.com/users/argon/events{/privacy}","received_events_url":"https://api.github.com/users/argon/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T08:20:43Z","updated_at":"2015-05-19T08:20:43Z","body":"I can't seen anything obvious wrong there. The only thing i could suggest is adding an event handler for `socketError` just in case there's anything going wrong there."}}