I'm attempting to leverage notifications in an app that is in Swift 6 language mode. I have the following code: func startLocationUpdates() { //if self.manager.authorizationStatus == .notDetermined { // self.manager.requestWhenInUseAuthorization() //} self.logger.info(Starting location updates) Task { do { let updates = CLLocationUpdate.liveUpdates() for try await update in updates { if !self.updatesStarted { break } // End location updates by breaking out of the loop. self.lastUpdate = update if let loc = update.location { self.lastLocation = loc self.isStationary = update.stationary self.count += 1 self.logger.info(Location (self.count): (self.lastLocation)) } if lastUpdate!.insufficientlyInUse { let notification = UNNotificationRequest(identifier: com.example.mynotification, content: notificationContent, trigger: nil) try await UNUserNotificationCenter.current().add(notification) } } } catch { self.logger.error(Could not start location updates) } return } } As an aside, the above is directly taken
Topic:
App & System Services
SubTopic:
Notifications