То, что работало, перемещало Sinch и его инициализацию в AppDelegate и делало его доступным для других ViewControllers.
Так создайте Sinch Client один раз
var sinchObject : SINClient!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let client : SINClient = Sinch.client(withApplicationKey: appConstants.sinch_app_key, applicationSecret: appConstants.sinch_secret_key, environmentHost: appConstants.sinch_host, userId: "id@id.com")
client.setSupportCalling(true)
client.setSupportMessaging(true)
client.delegate = self
client.start()
sinchObject = client
return true
}
func applicationWillTerminate(_ application: UIApplication) {
sinchObject?.stop()
}
func clientDidStart(_ client: SINClient!) {
print("Start")
}
func clientDidStop(_ client: SINClient!) {
//print("Stop")
}
func clientDidFail(_ client: SINClient!, error: Error!) {
print(error.localizedDescription)
print(error)
print("Fail")
}
И в необходимом ViewController
func getSinchClient() -> SINClient {
let mainDelegate = UIApplication.shared.delegate as! AppDelegate
return mainDelegate.sinchObject!
}
func call(){
if (getSinchClient().isStarted()){
sinchCall = getSinchClient().call()?.callUserVideo(withId: callerId)
sinchCall!.delegate = self
}
}
func callDidProgress(_ call: SINCall!) {
print("Call Progress")
}
func callDidEnd(_ call: SINCall!) {
print("Call End")
print(call.details.endCause.rawValue)
}
func callDidAddVideoTrack(_ call: SINCall!) {
print("Call Got Video")
}
func callDidEstablish(_ call: SINCall!) {
print("Call Connected")
}