Industrial Binaries
1 min readFeb 24, 2020

When working on a project recently, I needed an easy solution for testing and debugging push notifications. So I wrote a Swift command-line tool allowing me to send notifications directly from the terminal: Lola. I’d like to share what I learned.

Example of lola usage

I’ll explain how to create a token for APNs and send notification from the terminal using Swift. This is not a step-by-step tutorial for full implementation. I’ll just be going over the most complicated part of the implementation process. If you want to look at the working code, you can check the terminal app lola.

APNs Request

Sending a notification is triggered by a POST request to the APNs. The request needs to be verified (otherwise anyone could send you a notification). There are two ways of doing that:

The first option is via a certificate-based connection. This requires establishing a connection with the server using a PEM certificate.

The second option is newer and (IMHO) a little bit easier. You can use token-based authentication. It’s done by adding a specific token to the request headers.

Continue reading on our website >>

Industrial Binaries
0 Followers

We Are World-Class Experts at Improving Existing iOS Codebases