Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KOSURUUDAYSAIKUMAR opened this issue Oct 3, 2024 · 0 comments
Open

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

KOSURUUDAYSAIKUMAR opened this issue Oct 3, 2024 · 0 comments

Comments

@KOSURUUDAYSAIKUMAR
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant