APNs integration issue
Hi all!
I'm trying to send a push notification with APNs. I've set the provider configuration, the template and the subscriber's token but when I'm trying to send it I get the error you can see below which I'm not sure what it is.
{
"stack": "Error: Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line\n at PushFactory.getHandler (/usr/src/app/apps/api/dist/main.js:16142:19)\n at SendMessagePush.<anonymous> (/usr/src/app/apps/api/dist/main.js:16089:54)\n at Generator.next (<anonymous>)\n at fulfilled (/usr/src/app/apps/api/dist/main.js:15948:58)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)",
"message": "Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line"
}
Do you have any idea about this?
Thanks in advance!
14 Replies
@Support
FYI, 638f1b1c79b266fa794fd3e5 is my APNs provider and I'm pasting below its info:
{
"_id": "638f1b1c79b266fa794fd3e5",
"_environmentId": "6388d19079b266fa794fa157",
"_organizationId": "6388d19079b266fa794fa151",
"providerId": "apns",
"channel": "push",
"credentials": {
"secretKey": "-----BEGIN PRIVATE KEY----- my private key -----END PRIVATE KEY-----",
"apiKey": "my api key",
"projectName": "my team id"
},
"active": true,
"deleted": false,
"createdAt": "2022-12-06T10:36:12.964Z",
"updatedAt": "2022-12-21T10:35:45.265Z",
"__v": 0
}
@Engineering
The APNS integration was submitted by community and is currently in beta, so unfortuently this error might happen due to lack of different setup testing performed.
I'm personally not familiar with APNS a lot, but, @serafeimo are you familiar with this error message?
Nonetheless, do you mind submitting an issue on GitHub for this? So we can track it there and try to find someone with APNS experience to help
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I think I found something. When passing the "private key" from the dashboard it malforms it and then you get the above error.
If you update APNS provider using the API and pass the key there, then it seems ok.
Hmmm, maybe it's encoded somehow?
It seems so. I think that when it parses the key from the user input in dashboard, It replaces \n with whitespaces
@serafeimo, you just advanced to level 2!
Hi @serafeimo
Yes, it can be the cause of this error,
Can you please create a bug on github?
https://github.com/novuhq/novu/issues/new?assignees=&labels=type%3A+bug&template=bug_report.yml&title=%F0%9F%90%9B+Bug+Report%3A+
GitHub
🐛 Bug Report: APNS private key is not being parsed correctly · Iss...
📜 Description In APNS provider there is a field in order to set the private key. However, it seems that if someone copies the key and places it in that specific field, it's not getting pars...
Hello! Just found that here the
NODE_ENV
checks for value production
https://github.com/novuhq/novu/blob/2d3050a13b5dfc77b0d66e34ed2eac8a25299631/providers/apns/src/lib/apns.provider.ts#L28
However here the available option references that as prod
:
https://github.com/novuhq/novu/blob/8afc4161e2f6e6c12955071be450e545d1dba71b/apps/api/src/config/env-validator.ts#L15
It seems like an issue@rolkool might be related! But I even think that we shouldn't rely on process.env.node_env but on user specified boolean for that. Because novu will always run in prod environment for all users
@rolkool could you comment your findings on the GitHub issue please?
@dimagrossman I added a comment for the above