mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-17 20:08:31 +00:00
Check permissions before displaying the PermissionsFragment view
This commit is contained in:
parent
e981d5e0fe
commit
737a9880b6
2 changed files with 32 additions and 0 deletions
|
|
@ -149,6 +149,9 @@ struct WelcomeView: View {
|
|||
.clipped()
|
||||
}
|
||||
.frame(minHeight: geometry.size.height)
|
||||
.onAppear {
|
||||
PermissionManager.shared.havePermissionsAlreadyBeenRequested()
|
||||
}
|
||||
}
|
||||
|
||||
func setupAppearance() {
|
||||
|
|
|
|||
|
|
@ -126,4 +126,33 @@ class PermissionManager: ObservableObject {
|
|||
self.allPermissionsHaveBeenDisplayed = true
|
||||
}
|
||||
}
|
||||
|
||||
func havePermissionsAlreadyBeenRequested() {
|
||||
let cameraStatus = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
let micStatus = AVAudioSession.sharedInstance().recordPermission
|
||||
let photoStatus = PHPhotoLibrary.authorizationStatus(for: .readWrite)
|
||||
let contactsStatus = CNContactStore.authorizationStatus(for: .contacts)
|
||||
|
||||
let notifGroup = DispatchGroup()
|
||||
var notifStatus: UNAuthorizationStatus = .notDetermined
|
||||
|
||||
notifGroup.enter()
|
||||
UNUserNotificationCenter.current().getNotificationSettings { settings in
|
||||
notifStatus = settings.authorizationStatus
|
||||
notifGroup.leave()
|
||||
}
|
||||
|
||||
notifGroup.notify(queue: .main) {
|
||||
let allAlreadyRequested = cameraStatus != .notDetermined &&
|
||||
micStatus != .undetermined &&
|
||||
photoStatus != .notDetermined &&
|
||||
contactsStatus != .notDetermined &&
|
||||
notifStatus != .notDetermined
|
||||
|
||||
if allAlreadyRequested {
|
||||
self.allPermissionsHaveBeenDisplayed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue