I am trying to convert a firebase-queue
worker to send push notification to a cloud function. I am using node-apn
to send push notification to iOS devices. It requires setting up a connection which requires me to specify a key.pem
file and cert.pem
file. These files are present at the same location where the worker js file is present and works without any problem. I moved over the code to a cloud function but I get this error in the Logs console
{ Error: ENOENT: no such file or directory, open './cert.pem'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: './cert.pem' } 'Unable to send push notification to iOS device. Socket Error'
Below is how the files are specified and the connection is created in the code
var connectionOptions = {
cert:'./cert.pem',
key:'./key.pem',
production: true
};
var apnConnection = new apn.Connection(connectionOptions);
I have tried specifying the cert file as ./cert.pem
and cert.pem
but I get a similar error in both the cases. I guess the problem is that the .pem
files are not shipped along with the functions.
How can I specify such files in a cloud function?