Post

Replies

Boosts

Views

Activity

Reply to Searching for an example of a proper iBeacon implementation for iOS 17
I have used that example to create with the following code: import Foundation import CoreLocation let monitorName = "BeaconMonitor" let testBeaconId = UUID(uuidString: "EDFA3FFA-D80A-4C23-9104-11B5B0B8E8F3")! @MainActor public class ObservableMonitorModel: ObservableObject { private let manager: CLLocationManager public var monitor: CLMonitor? init() { self.manager = CLLocationManager() self.manager.requestWhenInUseAuthorization() self.manager.requestAlwaysAuthorization() } func startMonitoringConditions() { Task { monitor = await CLMonitor(monitorName) await monitor!.add(getBeaconIdentityCondition(), identifier: "Beacon") for identifier in await monitor!.identifiers { guard let lastEvent = await monitor!.record(for: identifier)?.lastEvent else { continue } print(identifier, lastEvent.state) } for try await event in await monitor!.events { print("Event", event.identifier, event) } } } } func getBeaconIdentityCondition() -> CLMonitor.BeaconIdentityCondition { CLMonitor.BeaconIdentityCondition(uuid: testBeaconId) } Unfortunately, running this on my iPhone only prints "Beacon CLMonitoringState". I don't see anything from the for try await block starting with "Event". Any ideas where I've gone wrong?
Jan ’24