From de57d77dc3940dcc6a08e1cd064b8acaa4319350 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 1 Jul 2020 09:50:49 +0300 Subject: [PATCH] fix issues in IOS OpenTok by Elham & Mohammad --- ios/Runner/AppDelegate.swift | 6 ++-- ios/Runner/ViewControlleraa.swift | 54 ++++++++++++------------------- lib/screens/dashboard_screen.dart | 12 ++----- 3 files changed, 26 insertions(+), 46 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 9bdc2717..5e32b165 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -45,9 +45,9 @@ import OpenTok let identifier = "ViewControllerNav" let navVC = storyboard.instantiateViewController(withIdentifier: identifier) as! UINavigationController let videoVC = navVC.viewControllers.first as! ViewController -// videoVC.kApiKey=kApiKey -// videoVC.kSessionId=kSessionId -// videoVC.kToken=kToken + videoVC.kApiKey=kApiKey + videoVC.kSessionId=kSessionId + videoVC.kToken=kToken videoVC.navigationController?.setNavigationBarHidden(true, animated: false) navVC.modalPresentationStyle = .fullScreen window.rootViewController?.present(navVC, animated: true, completion: nil) diff --git a/ios/Runner/ViewControlleraa.swift b/ios/Runner/ViewControlleraa.swift index 56629be8..d19a99d5 100644 --- a/ios/Runner/ViewControlleraa.swift +++ b/ios/Runner/ViewControlleraa.swift @@ -2,24 +2,13 @@ // ViewController.swift // Runner // -// Created by Mohammad Aljammal on 24/06/20. -// Copyright © 2020 tokbox. All rights reserved. +// Created by Mohammad Aljammal & Elham on 23/6/20. +// Copyright © 2020 The Chromium Authors. All rights reserved. // import UIKit import OpenTok -let kWidgetRatio: CGFloat = 1.333 - -// *** Fill the following variables using your own Project info *** -// *** https://tokbox.com/account/#/ *** -// Replace with your OpenTok API key -let kApiKey = "46803224" -// Replace with your generated session ID -let kSessionId = "2_MX40NjgwMzIyNH5-MTU5MzA3NDk2MjQxNH5QekwrY1oyaHdnbjVSaENkemlvNFVqeEJ-fg" -// Replace with your generated token -let kToken = "T1==cGFydG5lcl9pZD00NjgwMzIyNCZzaWc9ZTUxZGI0NGJiNjhjOGY2YzZkZGVjNTQ0M2Q5ZDJkODY2MjBlYjJjYTpzZXNzaW9uX2lkPTJfTVg0ME5qZ3dNekl5Tkg1LU1UVTVNekEzTkRrMk1qUXhOSDVRZWt3clkxb3lhSGRuYmpWU2FFTmtlbWx2TkZWcWVFSi1mZyZjcmVhdGVfdGltZT0xNTkzMDc1MDA3Jm5vbmNlPTAuNjQ2OTA2MTAwMTU0ODY3NSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNTkzNjc5ODA2JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9" - class ViewController: UIViewController { @@ -27,6 +16,12 @@ class ViewController: UIViewController { var publisher: OTPublisher? var subscriber: OTSubscriber? + var kApiKey:String = "" + + var kSessionId:String = "" + + var kToken:String = "" + override func viewDidLoad() { super.viewDidLoad() @@ -77,7 +72,7 @@ class ViewController: UIViewController { @IBAction func didClickSpeakerButton(_ sender: UIButton) { sender.isSelected = !sender.isSelected - subscriber!.subscribeToAudio = !sender.isSelected + subscriber?.subscribeToAudio = !sender.isSelected // resetHideButtonsTimer() } @@ -218,26 +213,6 @@ extension ViewController: OTSessionDelegate { func sessionDidConnect(_ session: OTSession) { print("The client connected to the OpenTok session.") -// let settings = OTPublisherSettings() -// settings.name = UIDevice.current.name -// guard let publisher = OTPublisher(delegate: self, settings: settings) else { -// return -// } -// -// var error: OTError? -// session.publish(publisher, error: &error) -// guard error == nil else { -// print(error!) -// return -// } -// -// guard let publisherView = publisher.view else { -// return -// } -// let screenBounds = UIScreen.main.bounds -// publisherView.frame = CGRect(x: screenBounds.width - 150 - 20, y: screenBounds.height - 150 - 20, width: 150, height: 150) -// view.addSubview(publisherView) -// setupPublisher() } @@ -266,6 +241,17 @@ extension ViewController: OTSessionDelegate { print("The client failed to connect to the OpenTok session: \(error).") } + func session( + _ session: OTSession, + connectionDestroyed connection: OTConnection + ) { + + if subscriber?.stream!.connection.connectionId == connection.connectionId { + cleanupSubscriber() + } + sessionDisconnect() + } + func session(_ session: OTSession, streamCreated stream: OTStream) { subscriber = OTSubscriber(stream: stream, delegate: self) diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index f4d6bb8b..037b344d 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -88,15 +88,9 @@ class _DashboardScreenState extends State { ), InkWell( onTap: () { - - VideoChannel.openVideoCallScreen(kApiKey: '46209962', - kSessionId: '_tokenData["OpenSessionID"]', - kToken: '', - ); - - // showCupertinoPicker( - // context: context, - // actionList: authProvider.doctorsClinicList); + showCupertinoPicker( + context: context, + actionList: authProvider.doctorsClinicList); }, child: Container( margin: