APIAlerts

1.1.0

Swift wrapper for the API Alerts service
apialerts/apialerts-swift

What's New

1.1.0 - Workspaces Support

2025-01-13T13:52:38Z

Added support for Workspaces!

  • optional channel property added to send functions
  • sendAsync functions are now exposed publicly if needed
  • added shorthand APIAlerts access - no longer need to use the underlying .client access. Can now simply call APIAlerts.configure(...) and APIAlerts.send(...)

Full Changelog: 1.0.1...1.1.0

apialerts-swift

Swift client for the apialerts.com platform

DocsGitHubSwift Package Index

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.

Feedback & Support

If you have any questions or feedback, please create an issue on our GitHub repository. We are always looking to improve our service and would love to hear from you. Thanks for using API Alerts!

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Apr 27 2025 13:58:41 GMT-0900 (Hawaii-Aleutian Daylight Time)