Swiftpack.co - hyperlink/hawk-client-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hyperlink.
hyperlink/hawk-client-swift 1.1.0
An (unofficial) Genesys Cloud WebSocket notifications client for macOS / iOS
⭐️ 0
🕓 4 weeks ago
iOS macOS tvOS
.package(url: "https://github.com/hyperlink/hawk-client-swift.git", from: "1.1.0")


Hawk Client for iOS/MacOS written in Swift


  • Subscribe to any topics and receive notification events in flexible swifty JSON format
  • Automatically attempts to reconnect after being disconnected
  • Listens to missed heartbeats and will reconnect if needed



  1. Create a client

  2. Subscribe to a topic or topics by calling async/await method subscribeToTopics(Set<String> topics) this will implicitly create a channel.

  3. Listen to events using the notificationMessage publisher

    Publisher will publish EventPayload struct made from a topic and swifty JSON message attributes

    public struct EventPayload {
        public let topic: String
        public let message: JSON
  1. Listen to socket events using the socketEvent publisher


func connectToHawk() async throws {
    let hawkClient = HawkClient(token: myAuthToken , host: "mypurecloud.com")
    let topics = try await hawkClient.subscribeToTopics(topics: Set(["v2.users.1ef53ada-ef64-4edf-a711-9970a534c7aa.presence"])))
    hawkClient.notificationMessage.sink(receiveValue: { payload in
        if payload.topic.hasSuffix(".presence") {
            // Do something with the eventBody
        } else {
            self.logger.error("Unknown topic \(payload.topic)")
    }).store(in: &cancellables)
    try hawkClient.connect()


Requires Swift 5 and Xcode 14

Swift Package Manager

Add the project as a dependency to your Package.swift:

// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "hawkclient-test",
    products: [
        .executable(name: "hawkclient-test", targets: ["YourTargetName"])
    dependencies: [
        .package(url: "https://github.com/hyperlink/hawk-client-swift", .upToNextMinor(from: "1.0.0"))
    targets: [
        .target(name: "YourTargetName", dependencies: ["HawkClient"], path: "./Path/To/Your/Sources")


Stars: 0
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics