Untitled
unknown
kotlin
25 days ago
1.1 kB
4
Indexable
Never
val eventHandler : (CLMonitor?, CLMonitoringEvent?) -> Unit = { _: CLMonitor?, clMonitoringEvent: CLMonitoringEvent? -> clMonitoringEvent?.let { event-> Datapoint() .apply { trackingId = ObjectId(event.identifier) participantId = ObjectId(userId) time = RealmInstant.from( epochSeconds = event.date.timeIntervalSince1970.toLong(), nanosecondAdjustment = 0, ) isPresent = event.state == CLMonitoringStateSatisfied _id = this.createCompositeId() }.also { datapoint -> datapointRealm.writeBlocking { copyToRealm(datapoint) } } } } val monitorConfiguration = CLMonitorConfiguration.configWithMonitorName( name = "talli_geofencing", queue = DISPATCH_QUEUE_CONCURRENT, eventHandler = eventHandler, ) CLMonitor.requestMonitorWithConfiguration(config = monitorConfiguration) { println("retrieved Monitor") Logger.i { "retrieved monitor" } locationMonitor = it!! }
Leave a Comment