{"action":"created","issue":{"url":"https://api.github.com/repos/argon/node-apn/issues/389","repository_url":"https://api.github.com/repos/argon/node-apn","labels_url":"https://api.github.com/repos/argon/node-apn/issues/389/labels{/name}","comments_url":"https://api.github.com/repos/argon/node-apn/issues/389/comments","events_url":"https://api.github.com/repos/argon/node-apn/issues/389/events","html_url":"https://github.com/argon/node-apn/issues/389","id":156913340,"number":389,"title":"InvalidToken error (errornum=8) on TransmissionError","user":{"login":"ickata","id":617081,"avatar_url":"https://avatars.githubusercontent.com/u/617081?v=3","gravatar_id":"","url":"https://api.github.com/users/ickata","html_url":"https://github.com/ickata","followers_url":"https://api.github.com/users/ickata/followers","following_url":"https://api.github.com/users/ickata/following{/other_user}","gists_url":"https://api.github.com/users/ickata/gists{/gist_id}","starred_url":"https://api.github.com/users/ickata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ickata/subscriptions","organizations_url":"https://api.github.com/users/ickata/orgs","repos_url":"https://api.github.com/users/ickata/repos","events_url":"https://api.github.com/users/ickata/events{/privacy}","received_events_url":"https://api.github.com/users/ickata/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-26T06:27:28Z","updated_at":"2016-05-28T11:49:48Z","closed_at":null,"body":"Hi all,\r\n\r\nI perfectly know that this issue is not related to node-apn module, but I really don't know where to look for a solution anymore. Apple cannot assist me.\r\n\r\nI'm trying to build a hybrid app using PhoneGap. I created a Push Notification registration following that example:\r\nhttps://github.com/phonegap/phonegap-plugin-push/blob/master/docs/EXAMPLES.md\r\n\r\nThe `\"onregistration\"` event returned me a `registrationId` property with a HEX value which I use as Device Token.\r\n\r\nThen I'm trying to send Push Notification using node-apn module. I'm executing the script from my Mac and here's the code:\r\n\r\n```\r\nvar http = require('http');\r\nvar apn = require('apn');\r\nvar url = require('url');\r\n \r\nvar myPhone = \"7e028f4d66d07...a568c350b257\";  // I'm not giving the whole token on purpose :)\r\n\r\nvar apnsConnection = new apn.Connection({\r\n   production  : false,\r\n   cert        : 'aps_development.pem',\r\n   key         : 'key.pem',\r\n   ca          : [ 'entrust_2048_ca.cer' ],\r\n   passphrase  : ''\r\n});\r\n \r\nvar myDevice = new apn.Device( myPhone );\r\n \r\nvar note = new apn.Notification();\r\nnote.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.\r\nnote.badge = 1;\r\nnote.sound = \"notification-beep.wav\";\r\nnote.alert = \"Hello tables!\";\r\nnote.payload = {'messageFrom': 'Tables'};\r\n\r\napnsConnection.on( 'error', function ( e ) {\r\n   console.log( 'Error', e );\r\n}).on( 'socketError', function ( e ) {\r\n   console.log( 'SocketError', e );\r\n}).on( 'transmitted', function ( note, id ) {\r\n   console.log( 'Transmitted', id );\r\n}).on( 'completed', function () {\r\n   console.log( 'Completed' );\r\n}).on( 'connected', function (sockets ) {\r\n   console.log( 'Connected', sockets );\r\n}).on( 'timeout', function () {\r\n   console.log( 'Timeout' );\r\n}).on( 'transmissionError', function ( code, note, id ) {\r\n   console.log( 'TransmissionError', code, id );\r\n});\r\n\r\napnsConnection.pushNotification( note, myDevice );\r\n```\r\n\r\nI followed these instructions for creating the required certificates from Apple Developer Center:\r\nhttps://www.raywenderlich.com/123862/push-notifications-tutorial\r\n\r\nI also downloaded entrust_2048_ca.cer from Entrust. \r\n\r\nI think that everything is fine with my certificates because executing this openssl command returns no errors:\r\n```\r\n$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert aps_development.pem -debug -showcerts -CAfile entrust_2048_ca.pem\r\n\r\n...\r\n    Start Time: 1464243673\r\n    Timeout   : 300 (sec)\r\n    Verify return code: 0 (ok)\r\n```\r\n\r\nStill, I am unable to send Push Notification to my device:\r\n\r\n```\r\nConnected 1\r\nTransmitted Device {\r\n  token: <Buffer 7e 02 8f 4d 07 b6 ... 5e 25 a5 68 c3 50 b2 57> }\r\nCompleted\r\nTransmissionError 8 Device {\r\n  token: <Buffer 7e 02 8f 4d 07 b6 ... 5e 25 a5 68 c3 50 b2 57> }\r\nConnected 1\r\n```\r\n\r\nThe TransmissionError event contains error code 8, which is \"InvalidToken\" error according to this table:\r\nhttps://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Appendixes/BinaryProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH106-SW1\r\n\r\nCan anybody tell me what am I doing wrong?"},"comment":{"url":"https://api.github.com/repos/argon/node-apn/issues/comments/222304584","html_url":"https://github.com/argon/node-apn/issues/389#issuecomment-222304584","issue_url":"https://api.github.com/repos/argon/node-apn/issues/389","id":222304584,"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":"2016-05-28T11:49:48Z","updated_at":"2016-05-28T11:49:48Z","body":"You can only use push notifications with an app that you have signed with your developer profile. If you are using another app downloaded from the store that will be tied to a different profile and give you a device token for that, not your profile and therefore it will be invalid."}}
{"actor":{"display_login":"argon"}}