ios – Apple Push Notifications from a serverless MongoDB App Providers backend
I’ve been organising Apple Push Notifications for an iOS app, utilizing JSON Internet Tokens relatively than certificates.
I can generate a JWT and make the required POST request from inside the app (utilizing the Swift-JWT package deal) and the notification is delivered.
Nonetheless, regardless of making an attempt a number of Node modules for making the POST request there have been all the time errors (like “BadDeviceToken” or “InvalidProviderToken”).
I lastly received it working utilizing the node-apn package deal! Nonetheless, I’ve two queries about utilizing it on this serverless perform context:
- It tries to maintain a connection open to the Apple server, which might be advantageous, besides it’d imply a brand new connection is opened each time the perform is known as. Calling
Supplier.shutdown()doesn’t appear to cease the connection. I don’t assume I can have a long-running course of to obtain future requests in a serverless context.
- Apple advise not refreshing the JWT extra usually than each 20 minutes.
node-apnmanages the JWT for you, however in a serverless context, will it’s producing a brand new token each time the perform is known as? Notifications do appear to get delivered each time I take a look at it in growth mode (to the Apple sandbox endpoint).
I’d be glad about readability on these factors, and whether or not
node-apn is acceptable to make use of in serverless capabilities.