From 4efc28da9ec344de20c591902a7d22e7d4e622b4 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Fri, 12 Jan 2024 15:54:03 +0100 Subject: [PATCH] Update push provider - use "apns.dev" or "apns" depending on wether we're using a DEBUG or RELEASE build --- Linphone/Core/CoreContext.swift | 18 +++++++++++++++++- .../Viewmodel/AccountLoginViewModel.swift | 7 ++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index d21138495..f69d10386 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -104,10 +104,25 @@ final class CoreContext: ObservableObject { } }) + self.mCoreSuscriptions.insert(self.mCore.publisher?.onGlobalStateChanged?.postOnCoreQueue { (cbVal: (core: Core, state: GlobalState, message: String)) in + if cbVal.state == GlobalState.On { +#if DEBUG + let pushEnvironment = ".dev" +#else + let pushEnvironment = "" +#endif + for account in cbVal.core.accountList where account.params?.pushNotificationConfig?.provider != ("apns" + pushEnvironment) { + let newParams = account.params?.clone() + Log.info("Account \(String(describing: newParams?.identityAddress?.asStringUriOnly())) - updating apple push provider from \(String(describing: newParams?.pushNotificationConfig?.provider)) to apns\(pushEnvironment)") + newParams?.pushNotificationConfig?.provider = "apns" + pushEnvironment + account.params = newParams + } + } + }) + self.mCore.videoCaptureEnabled = true self.mCore.videoDisplayEnabled = true - try? self.mCore.start() // Create a Core listener to listen for the callback we need // In this case, we want to know about the account registration status @@ -186,6 +201,7 @@ final class CoreContext: ObservableObject { self.mCore.iterate() } + try? self.mCore.start() } } diff --git a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift index 8cf56625f..819931bd3 100644 --- a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift +++ b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift @@ -91,7 +91,12 @@ class AccountLoginViewModel: ObservableObject { accountParams.registerEnabled = true accountParams.pushNotificationAllowed = true accountParams.remotePushNotificationAllowed = false - accountParams.pushNotificationConfig?.provider = "apns.dev" +#if DEBUG + let pushEnvironment = ".dev" +#else + let pushEnvironment = "" +#endif + accountParams.pushNotificationConfig?.provider = "apns" + pushEnvironment // Now that our AccountParams is configured, we can create the Account object let account = try core.createAccount(params: accountParams)