Fix provisioning click URI handler

This commit is contained in:
Benoit Martins 2025-04-24 10:03:54 +02:00
parent 49736388cf
commit 90231749c4
4 changed files with 20 additions and 13 deletions

View file

@ -255,16 +255,12 @@ final class CoreContext: ObservableObject {
}
}, onConfiguringStatus: { (_: Core, status: ConfiguringState, message: String) in
Log.info("New configuration state is \(status) = \(message)\n")
var accountModels: [AccountModel] = []
for account in self.mCore.accountList {
accountModels.append(AccountModel(account: account, core: self.mCore))
}
DispatchQueue.main.async {
if status == ConfiguringState.Successful {
/*
ToastViewModel.shared.toastMessage = "Success_qr_code_validated"
ToastViewModel.shared.displayToast = true
*/
var accountModels: [AccountModel] = []
for account in self.mCore.accountList {
accountModels.append(AccountModel(account: account, core: self.mCore))
}
self.accounts = accountModels
}
}

View file

@ -158,6 +158,9 @@ struct LinphoneApp: App {
ToastView()
.zIndex(3)
}
.onOpenURL { url in
URIHandler.handleURL(url: url)
}
} else if coreContext.accounts.isEmpty || sharedMainViewModel.displayProfileMode {
ZStack {
AssistantView()
@ -165,6 +168,9 @@ struct LinphoneApp: App {
ToastView()
.zIndex(3)
}
.onOpenURL { url in
URIHandler.handleURL(url: url)
}
} else if !coreContext.accounts.isEmpty
&& contactViewModel != nil
&& editContactViewModel != nil
@ -236,8 +242,6 @@ struct LinphoneApp: App {
meetingViewModel = MeetingViewModel()
conversationForwardMessageViewModel = ConversationForwardMessageViewModel()
accountProfileViewModel = AccountProfileViewModel()
}.onOpenURL { url in
URIHandler.handleURL(url: url)
}
}
}.onChange(of: scenePhase) { newPhase in

View file

@ -76,6 +76,8 @@ class Coordinator: NSObject, AVCaptureMetadataOutputObjectsDelegate {
core.stop()
try? core.start()
}
ToastViewModel.shared.toastMessage = "Success_qr_code_validated"
ToastViewModel.shared.displayToast = true
} else {
ToastViewModel.shared.toastMessage = "Invalide URI"
ToastViewModel.shared.displayToast.toggle()

View file

@ -90,12 +90,17 @@ class URIHandler {
private static func initiateConfiguration(url: URL) {
if autoRemoteProvisioningOnConfigUriHandler() {
CoreContext.shared.performActionOnCoreQueueWhenCoreIsStarted { core in
CoreContext.shared.doOnCoreQueue { core in
Log.info("[URIHandler] provisioning app with URI: \(url.resourceSpecifier)")
do {
addCoreDelegate()
core.config?.setString(section: "misc", key: "config-uri", value: url.resourceSpecifier)
try core.setProvisioninguri(newValue: url.resourceSpecifier)
var urlString = url.resourceSpecifier
if urlString.starts(with: "//") {
urlString = String(urlString.dropFirst(2))
}
core.config?.setString(section: "misc", key: "config-uri", value: urlString)
try core.setProvisioninguri(newValue: urlString)
core.stop()
try core.start()
} catch {