ProductCrafters / react-native-ios-push-notifications-example

12 stars 6 forks source link

Failed to generate token #2

Open sanealytics opened 5 years ago

sanealytics commented 5 years ago

I'm not familiar with apn, and keep getting this error when I try to push it -

Invalid APN params { VError: Failed to generate token: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at prepareToken (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/credentials/token/prepare.js:45:13)
    at config (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/config.js:43:31)
    at new Client (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/client.js:11:19)
    at new Provider (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/provider.js:12:19)
    at new Notification (/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:10:21)
    at Object.<anonymous> (/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:52:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
  jse_shortmsg: 'Failed to generate token',
  jse_cause:
   Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
       at Sign.sign (internal/crypto/sig.js:84:26)
       at sign (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/jwa/index.js:152:45)
       at Object.sign (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/jwa/index.js:192:27)
       at Object.jwsSign [as sign] (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/jws/lib/sign-stream.js:32:24)
       at module.exports (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/jsonwebtoken/sign.js:204:16)
       at prepareToken (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/credentials/token/prepare.js:27:18)
       at config (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/config.js:43:31)
       at new Client (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/client.js:11:19)
       at new Provider (/Users/saurabh/Documents/react-native-ios-push-notifications-example/node_modules/apn/lib/provider.js:12:19)
       at new Notification (/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:10:21),
  jse_info: {},
  message:
   'Failed to generate token: error:0906D06C:PEM routines:PEM_read_bio:no start line' }
/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:24
      throw new Error('No apn connection')
      ^

Error: No apn connection
    at Notification.sendNotification (/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:24:13)
    at Object.<anonymous> (/Users/saurabh/Documents/react-native-ios-push-notifications-example/pushServer.js:54:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:266:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)

I have ios_development.cer in the local directory and have checked the params again, but can't get this to work.... please help.

reactdevrocks commented 5 years ago

@sanealytics have you find any solution? i am also getting this error?

sanealytics commented 5 years ago

Not yet :( I sorta gave up on this functionality. If I end up going back to it, I will update here with the solution.