Swift
Swift 6, iOS 15+ / macOS 12+
Structured-concurrency native: async/await calls, AsyncSequence streams, and a separate ingest client for device credentials. Distributed as a Swift Package from a public repository.
Install
.package(url: "https://github.com/EngMohamed05/bardiya-swift", from: "0.1.0")What it supports
- Maps, places, geocoding, directions and matrix
- Tracking sessions, ingest and history
- AsyncSequence streams with resume
- Webhook signature verification helpers
Initialise the client
swift
import BardiyaMap
let client = BardiyaClient { options in
options.mapsAPIKey = ProcessInfo.processInfo.environment["BARDIYA_MAPS_KEY"]
options.trackingAPIKey = ProcessInfo.processInfo.environment["BARDIYA_TRACKING_KEY"]
}
let places = try await client.searchPlaces(
q: "coffee",
latitude: 30.0444,
longitude: 31.2357,
limit: 5
)
print(places.count)Typical operations
Device ingest
swift
// Backend, with the organization tracking key:
let credential = try await client.issueIngestToken(sessionId)
// Device, with only that credential:
let ingest = client.ingest(credential: credential.token, organizationId: organizationId)
try await ingest.sendLocation(sessionId, event: event)Stream
swift
for try await frame in try client.streamSession(sessionId) {
if frame.type == "location" { print(frame.id ?? "", frame.data) }
}Things that catch people out
- Add the package from the public repository. A local path dependency or a fork of the private application repository will not resolve for anyone else.
- The client is an actor-isolated type; calls are safe from any task.
