Update push provider - use "apns.dev" or "apns" depending on wether we're using a DEBUG or RELEASE build

This commit is contained in:
QuentinArguillere 2024-01-12 15:54:03 +01:00
parent e66a0802f5
commit 4efc28da9e
2 changed files with 23 additions and 2 deletions

View file

@ -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()
}
}

View file

@ -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)