CLMonitor Beacon Example is Nonfunctional

I have used this example to create 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?

Try putting some distance between yourself and the beacon to simulate proximity changes or turn the beacon off and on to see if it triggers an event and/or identifier state event.

CLMonitor Beacon Example is Nonfunctional
 
 
Q