-
Notifications
You must be signed in to change notification settings - Fork 37
π Getting started
It's really easy to get started with the VaporAPNS library! First you need to import the library, by adding this to the top of your Swift file:
import VaporAPNS
Then you need to get yourself an instance of the VaporAPNS class.
There are two ways you can initiate VaporAPNS. You can either use the new authentication key APNS authentication method or the 'old'/traditional certificates method.
This is the easiest to setup authentication method. Also the token never expires so you won't have to renew the private key (unlike the certificates which expire at a certain date).
let options = try! Options(topic: "<your bundle identifier>", teamId: "<your team identifier>", keyId: "<your key id>", keyPath: "/path/to/your/APNSAuthKey.p8")
let vaporAPNS = try VaporAPNS(options: options)
If you decide to go with the more traditional authentication method, you need to convert your push certificate, using:
openssl pkcs12 -in Certificates.p12 -out push.crt.pem -clcerts -nokeys
openssl pkcs12 -in Certificates.p12 -out push.key.pem -nocerts -nodes
After you have those two files you can go ahead and create a VaporAPNS instance:
let options = try! Options(topic: "<your bundle identifier>", certPath: "/path/to/your/certificate.crt.pem", keyPath: "/path/to/your/certificatekey.key.pem")
let vaporAPNS = try VaporAPNS(options: options)