Contents

apialerts/apialerts-swift

Swift SDK for the API Alerts notification platform

Installation

Add the following dependency to your Package.swift file

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/apialerts/apialerts-swift.git", exact: "<latest-version>")
    ],
    targets: [
        .target(
            ...
            dependencies: [
                .product(name: "APIAlerts", package: "apialerts-swift"),
            ]
        )
    ]

or install it via your xcode project

https://github.com/apialerts/apialerts-swift.git

Currently, apialerts-swift is only available as an SPM package.

Initialize the client

import APIAlerts
...

// Set the default api key to use in all send() calls at any time in your app
APIAlerts.configure(
    apiKey: "your-api-key"
)

Configuring the client is optional, but it allows you to set a default API Key for all send() calls. You must set an API key in the send() call if you do not configure the client.

Send Events

Quick one-liner to send a notification to your connected devices.

APIAlerts.send(
    apiKey: "your-api-key",   // Optional, uses the key from ApiAlerts.client.configure() if not provided
    channel: "your-channel",  // Optional, uses the default channel if not provided
    message: "New App User!"  // Required
)

Additional event properties can be set using the optional parameters.

APIAlerts.send(
    apiKey: "your-api-key",        // Optional, uses the key from ApiAlerts.client.configure() if not provided
    channel: "your-channel",       // Optional, uses the default channel if not provided
    message: "New App User!",      // Required
    tags: ["tag1", "tag2"],        // Optional tags
    link: "https://apialerts.com"  // Optional link
)

The API Key provided in the send() function can be different from the default API Key set in the configure() function. This allows you to send events to different workspaces without changing the default API Key or managing multiple instances of the client.

The APIAlerts.sendAsync methods are also available if you need to wait for a successful execution. However, the send() functions are generally always preferred.

Package Metadata

Repository: apialerts/apialerts-swift

Homepage: https://apialerts.com/docs/sdks/swift

Stars: 2

Forks: 0

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

Topics: api-client, apialerts, ios, macos, notifications, sdk, swift

README: README.md