diff --git a/Linphone/UI/Welcome/WelcomeView.swift b/Linphone/UI/Welcome/WelcomeView.swift index c207a9518..31433f634 100644 --- a/Linphone/UI/Welcome/WelcomeView.swift +++ b/Linphone/UI/Welcome/WelcomeView.swift @@ -149,6 +149,9 @@ struct WelcomeView: View { .clipped() } .frame(minHeight: geometry.size.height) + .onAppear { + PermissionManager.shared.havePermissionsAlreadyBeenRequested() + } } func setupAppearance() { diff --git a/Linphone/Utils/PermissionManager.swift b/Linphone/Utils/PermissionManager.swift index dab08971b..61372987f 100644 --- a/Linphone/Utils/PermissionManager.swift +++ b/Linphone/Utils/PermissionManager.swift @@ -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 + } + } + } + }