first step form calling API

merge-requests/147/head
Elham Rababah 6 years ago
parent 1e27edf09f
commit 693effd6b7

@ -64,7 +64,7 @@ target 'Runner' do
# Keep pod path relative so it can be checked into Podfile.lock. # Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter' pod 'Flutter', :path => 'Flutter'
pod 'OpenTok' pod 'OpenTok'
pod 'Alamofire'
# Plugin Pods # Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock

@ -1,4 +1,5 @@
PODS: PODS:
- Alamofire (4.9.1)
- barcode_scan (0.0.1): - barcode_scan (0.0.1):
- Flutter - Flutter
- MTBBarcodeScanner - MTBBarcodeScanner
@ -41,6 +42,7 @@ PODS:
- Flutter - Flutter
DEPENDENCIES: DEPENDENCIES:
- Alamofire
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
- connectivity (from `.symlinks/plugins/connectivity/ios`) - connectivity (from `.symlinks/plugins/connectivity/ios`)
- connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`) - connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`)
@ -62,6 +64,7 @@ DEPENDENCIES:
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- Alamofire
- MTBBarcodeScanner - MTBBarcodeScanner
- OpenTok - OpenTok
- Reachability - Reachability
@ -104,6 +107,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_web/ios" :path: ".symlinks/plugins/url_launcher_web/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75 connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75
connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191 connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191
@ -126,6 +130,6 @@ SPEC CHECKSUMS:
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313 url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
PODFILE CHECKSUM: ad71cae222b2dc22820a69b80873417b35fef79e PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69
COCOAPODS: 1.9.3 COCOAPODS: 1.9.3

@ -11,8 +11,12 @@ import OpenTok
var result: FlutterResult? var result: FlutterResult?
func sessionDone() { func sessionDone(res:Any) {
self.result?("Session Done") self.result?(res)
}
func sessionNotResponded(res:Any) {
self.result?(res)
} }
override func application( override func application(
@ -20,7 +24,6 @@ import OpenTok
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let videoCallChannel = FlutterMethodChannel(name: "Dr.cloudSolution/videoCall", let videoCallChannel = FlutterMethodChannel(name: "Dr.cloudSolution/videoCall",
binaryMessenger: controller.binaryMessenger) binaryMessenger: controller.binaryMessenger)

@ -10,5 +10,6 @@ import Foundation
protocol ICallProtocol { protocol ICallProtocol {
func sessionDone() func sessionDone(res:Any)
func sessionNotResponded(res: Any)
} }

@ -8,6 +8,7 @@
import UIKit import UIKit
import OpenTok import OpenTok
import Alamofire
class ViewController: UIViewController { class ViewController: UIViewController {
@ -25,6 +26,7 @@ class ViewController: UIViewController {
var callBack: ICallProtocol? var callBack: ICallProtocol?
var timer = Timer() var timer = Timer()
var seconds = 30 var seconds = 30
var isUserConnect : Bool = false
override func viewDidLoad() { override func viewDidLoad() {
@ -38,6 +40,38 @@ class ViewController: UIViewController {
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
private func callApi() {
let URL_USER_REGISTER = "https://uat.hmgwebservices.com/LiveCareApi/DoctorApp/GetSessionStatus"
let headers: HTTPHeaders = [
"Content-Type":"application/json",
"Accept":"application/json",
]
let parameters = [
"VC_ID": 3245,
"TokenID": "hfkjshdf347r8743",
"generalid": "Cs2020@2016$2958",
"DoctorId" : 1485 ,
] as [String : Any]
Alamofire.request(URL_USER_REGISTER, method: .post,parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON{
response in
if self.isUserConnect {
} else {
if let result = response.result.value {
let jsonData = result as! NSDictionary
self.callBack?.sessionNotResponded(res: ["sessionStatus":jsonData, "callResponse":"CallNotRespond"])
}
self.sessionDisconnect();
self.timer.invalidate()
}
//getting json value from the server
}
}
func setupButtons() { func setupButtons() {
perform(#selector(hideControlButtons), with: nil, afterDelay: 3) perform(#selector(hideControlButtons), with: nil, afterDelay: 3)
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(remoteVideoTapped(_:))) let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(remoteVideoTapped(_:)))
@ -115,7 +149,7 @@ class ViewController: UIViewController {
if (session != nil) { if (session != nil) {
print("disconnecting....") print("disconnecting....")
session!.disconnect(nil) session!.disconnect(nil)
callBack?.sessionDone() callBack?.sessionDone(res:["callResponse":"CallEnd"])
dismiss(animated: true) dismiss(animated: true)
return return
} }
@ -214,10 +248,10 @@ class ViewController: UIViewController {
seconds -= 1 //This will decrement(count down)the seconds. seconds -= 1 //This will decrement(count down)the seconds.
print(seconds) print(seconds)
if seconds == 0 { if seconds == 0 {
sessionDisconnect(); callApi()
timer.invalidate()
} }
} }
} }
@ -330,7 +364,7 @@ extension ViewController: OTSessionDelegate {
if let connectionId = connection?.connectionId { if let connectionId = connection?.connectionId {
print("session connectionCreated (\(connectionId))") print("session connectionCreated (\(connectionId))")
} }
isUserConnect = true
timer.invalidate() timer.invalidate()
} }

Loading…
Cancel
Save