Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

πŸš€ Getting started

Matthijs Logemann edited this page Apr 13, 2017 · 1 revision

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.

πŸ”’ Authentication methods

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.

πŸ”‘ Authentication key authentication (preferred)

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)

🎫 Certificate authentication

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)