A helper tool for sending push notifications from the terminal written in Swift.
If you want to run lola in the terminal, clone the repo:
$ git clone https://github.com/industrialbinaries/lola
$ cd lolaAnd then install it with Make:
$ make installlola is also distributed via SPM. You can use it as a framework in your macOS or iOS project.
In your Package.swift add a new package depedency:
.package(
url: "https://github.com/industrialbinaries/lola",
from: "0.1.0"
)To send push notifications from the terminal with lola you need to use the following parameters:
-
bundleId- bundle the ID of your app -
device- device token or the device you want to send the notification to -
teamId- Apple Developer Team ID, you can find it in your Account ->Membership->Team ID -
authKey- Name of yourp8 filecreated in Apple Keys -
notificationType- This parameter is optional, when is not set payload will be sent with default valuealert. Can be one of 6 valuesalert, background, VOIP, complication, fileprovider, mdm -
json- JSON payload of your notification. Eitherjsonormessagevalue has to be specified. -
message- The notification will be sent as an alert with the provided text. This is a convenient option instead of providigin the fulljsonpayload.
$ lola \
-bundleId co.industrial-binaries.LolaTestApp \
-device d9f1767bdbf0371f5efb25c7873f1942cf570ececde9896913ed9fdb33ac1c26 \
-teamId 9Q6922742Y \
-authKey AuthKey_JP8Z7XXKD9.p8 \
-message "Hi from lola 👋"$ lola \
-bundleId co.industrial-binaries.LolaTestApp \
-device d9f1767bdbf0371f5efb25c7873f1942cf570ececde9896913ed9fdb33ac1c26 \
-teamId 9Q6922742Y \
-authKey AuthKey_JP8Z7XXKD9.p8 \
-notificationType alert \
-json "{ \"aps\": {\"alert\": \"Hi from lola 👋\", \"sound\": \"default\" }}"- Get the authorization token from your P8 file using
P8Parser:
let parser = try P8Parser(
p8: /** Key of your P8 **/,
teamID: /** Team ID of your Apple Developer account **/
)
let authorizationToken = try parser.generateToken()- Create a new instance of
Lola:
let configuration = AppConfiguration(
deviceToken: /** Your app Push token **/,
authorizationToken: /** Token from your P8 key **/,
bundleId: /** Bundle-id of your app **/
)
let lola = Lola(configuration: configuration)- Use
lolato send notifications by providing aJSONpayload:
lola.send(
payload: /** Notification payload - JSON in string **/,
type: /** Notification type **/,
completion: /** Your completion block **/
)... or just a simple message:
lola.send(
message: /** Notification message - notification description **/,
completion: /** Your completion block **/
)lola is released under the MIT license. See LICENSE for details.
Created by Jan Timar @ Industrial Binaries.
