Update createAndInitializeAccount common function for easier push settings understanding
This commit is contained in:
parent
a63960ab0b
commit
b2bc5b1b12
@ -66,14 +66,8 @@ class CallKitExampleContext : ObservableObject
|
||||
func createAccountAndRegister() {
|
||||
if (!loggedIn) {
|
||||
do {
|
||||
account = try createAndInitializeAccount(core : mCore, identity: id, password: passwd)
|
||||
|
||||
// This is necessary to register to the server and handle push Notifications. Make sure you have a certificate to match your app's bundle ID.
|
||||
let updatedPushParams = account.params?.clone()
|
||||
updatedPushParams?.pushNotificationConfig?.provider = "apns.dev"
|
||||
updatedPushParams?.pushNotificationAllowed = true
|
||||
account.params = updatedPushParams
|
||||
|
||||
account = try createAndInitializeAccount(core : mCore, identity: id, password: passwd, withVoipPush: true)
|
||||
|
||||
try mCore.addAccount(account: account!)
|
||||
if ( mCore.defaultAccount == nil) {
|
||||
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !
|
||||
|
@ -6,7 +6,7 @@ import Foundation
|
||||
import linphonesw
|
||||
|
||||
|
||||
func createAndInitializeAccount(core: Core, identity: String, password: String) throws -> Account {
|
||||
func createAndInitializeAccount(core: Core, identity: String, password: String, withVoipPush: Bool = false, withRemotePush: Bool = false) throws -> Account {
|
||||
let factory = Factory.Instance
|
||||
let accountParams = try core.createAccountParams()
|
||||
let address = try factory.createAddress(addr: identity)
|
||||
@ -16,6 +16,11 @@ func createAndInitializeAccount(core: Core, identity: String, password: String)
|
||||
try accountParams.setServeraddr(newValue: "sip:" + address.domain + ";transport=tls")
|
||||
accountParams.registerEnabled = true
|
||||
|
||||
// This is necessary to register to the server and handle push Notifications. Make sure you have a certificate to match your app's bundle ID.
|
||||
accountParams.pushNotificationConfig?.provider = "apns.dev"
|
||||
|
||||
accountParams.pushNotificationAllowed = withVoipPush
|
||||
accountParams.remotePushNotificationAllowed = withRemotePush
|
||||
core.addAuthInfo(info: info)
|
||||
return try core.createAccount(params: accountParams)
|
||||
}
|
||||
@ -39,7 +44,7 @@ class LoggingUnit
|
||||
var logsEnabled : BoolHolder!
|
||||
func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
||||
if (logsEnabled.value) {
|
||||
print("Linphone logs: \(message)\n")
|
||||
print("Linphone logs: \(message)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user