mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-01 21:56:58 +02:00
MESSENGER-4235 - location sharing without gps
This commit is contained in:
+27
-4
@@ -60,7 +60,8 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
case .share:
|
||||
// Share current user location
|
||||
guard let location = state.bindings.userLocation else {
|
||||
processError(.failedLocatingUser)
|
||||
// bwi: check if app has gps access and show the desired error
|
||||
showMissingLocationError()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -73,8 +74,13 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
|
||||
completion?(.share(latitude: pinLocation.latitude, longitude: pinLocation.longitude, coordinateType: .pin))
|
||||
case .goToUserLocation:
|
||||
state.showsUserLocation = true
|
||||
state.isPinDropSharing = false
|
||||
// bwi: check if userLocation is available
|
||||
if state.bindings.userLocation == nil {
|
||||
showMissingLocationError()
|
||||
} else {
|
||||
state.showsUserLocation = true
|
||||
state.isPinDropSharing = false
|
||||
}
|
||||
case .startLiveSharing:
|
||||
startLiveLocationSharing()
|
||||
case .shareLiveLocation(let timeout):
|
||||
@@ -140,10 +146,11 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
state.bindings.alertInfo = AlertInfo(id: .userLocatingError,
|
||||
title: VectorL10n.locationSharingLocatingUserErrorTitle(AppInfo.current.displayName),
|
||||
primaryButton: (VectorL10n.ok, primaryButtonCompletion))
|
||||
// bwi: The user should be able to set a location without GPS
|
||||
case .invalidLocationAuthorization:
|
||||
state.bindings.alertInfo = AlertInfo(id: .authorizationError,
|
||||
title: VectorL10n.locationSharingInvalidAuthorizationErrorTitle(AppInfo.current.displayName),
|
||||
primaryButton: (VectorL10n.locationSharingInvalidAuthorizationNotNow, primaryButtonCompletion),
|
||||
primaryButton: (VectorL10n.locationSharingInvalidAuthorizationNotNow, {return}),
|
||||
secondaryButton: (VectorL10n.locationSharingInvalidAuthorizationSettings, {
|
||||
UIApplication.shared.vc_openSettings()
|
||||
}))
|
||||
@@ -196,4 +203,20 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private func showMissingLocationError() {
|
||||
locationSharingService.requestAuthorization { [weak self] authorizationStatus in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
switch authorizationStatus {
|
||||
case .denied, .unknown:
|
||||
self.processError(.invalidLocationAuthorization)
|
||||
case .authorizedAlways:
|
||||
self.processError(.failedLocatingUser)
|
||||
case .authorizedInForeground:
|
||||
self.processError(.failedLocatingUser)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user