Skip to content

[Feature]: Work flow status, service. #388

@KOSURUUDAYSAIKUMAR

Description

@KOSURUUDAYSAIKUMAR

What problem are you facing?

View did load () {
authorizationStatus()
}

func locationServiceStatus() {
Task(operation: {
for await event in await location.startMonitoringLocationServices() {
if event.isLocationEnabled {
self.continousLocationMonitoring()
} else {
AlertHelper.showAlert(title: StaticString.alertTitle, message: "camera_permission".localize(), viewController: self) {
DashboardViewModel.shared.openLocationSettings()
}
}
print("Location Services are (event.isLocationEnabled ? "enabled" : "disabled")")
break
}
})
}

func authorizationStatus() {
    Task(operation: {
        try await location.requestPermission(.whenInUse) // obtain the permissions
        let userLocation = try await location.requestLocation() // get the location
        
        for await event in await location.startMonitoringAuthorization() {
          print("Authorization status did change: \(event.authorizationStatus)")
            switch event.authorizationStatus {
            case .authorizedAlways, .authorizedWhenInUse:
                let obtaninedStatus = try await location.requestPermission(.whenInUse)
                self.locationServiceStatus()
            case .notDetermined, .restricted, .denied :
                AlertHelper.showAlert(title: StaticString.alertTitle, message: "location_failure".localize(), viewController: self) {
                    DashboardViewModel.shared.openLocationSettings()
                }
            default:
                return
            }
            break
        }
    })
}

func continousLocationMonitoring() {
  Task(operation: {
        for await event in try await self.location.startMonitoringLocations() {
            switch event {
            case .didPaused:
                PrintLog.info("location did paused startMonitoringLocations")
                break
            // stream paused
            case .didResume:
                PrintLog.info("location did resume startMonitoringLocations")
                break
            // stream resumed
            case .didUpdateLocations(let locations):
                debugPrint("locations startMonitoringLocations -----------", locations)
                for location in locations {
                    processMapCurrentLocation(location: location)
                }
            // new locations received
            case let .didFailed(error):
                PrintLog.info("location did fail with error startMonitoringLocations \(error.localizedDescription)")
                break
            // an error has occured
            }
            // break to stop the stream
        }
    })
}

Issue: It is not navigating inside of the for loop function of above statement locationServiceStatus() and authorizationStatus() 

can you please help me how can I fix. 

Other Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions