{"id":16828029,"url":"https://github.com/hyperlink/hawk-client-swift","last_synced_at":"2025-03-17T20:29:34.245Z","repository":{"id":136841329,"uuid":"591334943","full_name":"hyperlink/hawk-client-swift","owner":"hyperlink","description":"An (unofficial) Genesys Cloud WebSocket notifications client for macOS / iOS","archived":false,"fork":false,"pushed_at":"2025-03-11T14:34:15.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T15:43:54.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperlink.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-20T14:04:46.000Z","updated_at":"2025-03-11T14:33:54.000Z","dependencies_parsed_at":"2024-04-09T17:49:11.453Z","dependency_job_id":null,"html_url":"https://github.com/hyperlink/hawk-client-swift","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperlink%2Fhawk-client-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperlink%2Fhawk-client-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperlink%2Fhawk-client-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperlink%2Fhawk-client-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperlink","download_url":"https://codeload.github.com/hyperlink/hawk-client-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244105265,"owners_count":20398833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T11:24:15.309Z","updated_at":"2025-03-17T20:29:34.217Z","avatar_url":"https://github.com/hyperlink.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HawkClient\n\nHawk Client for iOS/MacOS written in Swift\n\n## Features\n\n* Subscribe to any topics and receive notification events in flexible [swifty JSON](https://github.com/SwiftyJSON/SwiftyJSON) format\n* Automatically attempts to reconnect after being disconnected\n* Listens to missed heartbeats and will reconnect if needed\n\n## Usage\n\n### Steps\n\n1. Create a client\n2. Subscribe to a topic or topics by calling async/await method `subscribeToTopics(Set\u003cString\u003e topics)` this will implicitly create a channel.\n3. Listen to events using the `notificationMessage` [publisher](https://developer.apple.com/documentation/combine/publisher)\n\n    Publisher will publish `EventPayload` struct made from a `topic` and [swifty JSON](https://github.com/SwiftyJSON/SwiftyJSON) `message` attributes\n\n```swift\n    public struct EventPayload {\n        public let topic: String\n        public let message: JSON\n    }\n```\n\n4. Listen to socket events using the `socketEvent` [publisher](https://developer.apple.com/documentation/combine/publisher)\n\n### Example\n\n```swift\nfunc connectToHawk() async throws {\n    let hawkClient = HawkClient(token: myAuthToken , host: \"mypurecloud.com\")\n    let topics = try await hawkClient.subscribeToTopics(topics: Set([\"v2.users.1ef53ada-ef64-4edf-a711-9970a534c7aa.presence\"])))\n    hawkClient.notificationMessage.sink(receiveValue: { payload in\n        if payload.topic.hasSuffix(\".presence\") {\n            // Do something with the eventBody\n            payload.message[\"eventBody\"]\n        } else {\n            self.logger.error(\"Unknown topic \\(payload.topic)\")\n        }\n    }).store(in: \u0026cancellables)\n    try hawkClient.connect()\n}\n```\n## Install\n\nRequires Swift 5 and Xcode 14\n\n### Swift Package Manager\n\nAdd the project as a dependency to your Package.swift:\n```swift\n// swift-tools-version:4.2\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"hawkclient-test\",\n    products: [\n        .executable(name: \"hawkclient-test\", targets: [\"YourTargetName\"])\n    ],\n    dependencies: [\n        .package(url: \"https://github.com/hyperlink/hawk-client-swift\", .upToNextMinor(from: \"1.0.0\"))\n    ],\n    targets: [\n        .target(name: \"YourTargetName\", dependencies: [\"HawkClient\"], path: \"./Path/To/Your/Sources\")\n    ]\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperlink%2Fhawk-client-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperlink%2Fhawk-client-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperlink%2Fhawk-client-swift/lists"}