diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index e4992e16..0a5ed700 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -38,7 +38,11 @@ import OpenTok let kSessionId = arguments!["kSessionId"] as? String let kToken = arguments!["kToken"] as? String let appLang = arguments!["appLang"] as? String - self.openVideoChat(result: result,kApiKey: kApiKey!,kSessionId:kSessionId!,kToken: kToken!, appLang: appLang!) + let vC_ID = arguments!["VC_ID"] as? Int + let tokenID = arguments!["TokenID"] as? String + let generalId = arguments!["generalId"] as? String + let doctorId = arguments!["DoctorId"] as? Int + self.openVideoChat(result: result,kApiKey: kApiKey!,kSessionId:kSessionId!,kToken: kToken!, appLang: appLang!, vC_ID: vC_ID!,tokenID: tokenID!,generalId: generalId!,doctorId: doctorId!) } default: result(FlutterMethodNotImplemented) @@ -52,7 +56,7 @@ import OpenTok - private func openVideoChat(result: FlutterResult,kApiKey: String, kSessionId: String,kToken: String,appLang:String) { + private func openVideoChat(result: FlutterResult,kApiKey: String, kSessionId: String,kToken: String,appLang:String, vC_ID: Int,tokenID:String,generalId:String,doctorId:Int) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let identifier = "ViewControllerNav" @@ -61,6 +65,11 @@ import OpenTok videoVC.kApiKey=kApiKey videoVC.kSessionId=kSessionId videoVC.kToken=kToken + videoVC.VC_ID = vC_ID + videoVC.generalid = generalId + videoVC.TokenID = tokenID + videoVC.DoctorId = doctorId + videoVC.callBack = self videoVC.navigationController?.setNavigationBarHidden(true, animated: false) navVC.modalPresentationStyle = .fullScreen diff --git a/ios/Runner/VideoViewController.swift b/ios/Runner/VideoViewController.swift index d9834fea..3ff2eef5 100644 --- a/ios/Runner/VideoViewController.swift +++ b/ios/Runner/VideoViewController.swift @@ -23,6 +23,11 @@ class ViewController: UIViewController { var kToken:String = "" + var VC_ID: Int = 0 + var TokenID: String = "" + var generalid : String = "" + var DoctorId: Int = 0 + var callBack: ICallProtocol? var timer = Timer() var seconds = 30 @@ -41,7 +46,7 @@ class ViewController: UIViewController { } - private func callApi() { + private func getSessionStatus() { let URL_USER_REGISTER = "https://uat.hmgwebservices.com/LiveCareApi/DoctorApp/GetSessionStatus" let headers: HTTPHeaders = [ "Content-Type":"application/json", @@ -50,19 +55,27 @@ class ViewController: UIViewController { ] let parameters = [ - "VC_ID": 3245, - "TokenID": "hfkjshdf347r8743", - "generalid": "Cs2020@2016$2958", - "DoctorId" : 1485 , + "VC_ID": VC_ID, + "TokenID": TokenID, + "generalid": generalid, + "DoctorId" : DoctorId , ] 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"]) - + let jsonData = result as! NSObject + if((jsonData.value(forKey: "SessionStatus")) as! Int == 2 || (jsonData.value(forKey: "SessionStatus")) as! Int == 3) { + //jsonData + let jsonObject: [String: Any] = [ + "sessionStatus": result , + "callResponse": "CallNotRespond", + ] + self.callBack?.sessionNotResponded(res: jsonObject) + + } + } self.sessionDisconnect(); self.timer.invalidate() @@ -140,7 +153,7 @@ class ViewController: UIViewController { } @IBAction func hangUp(_ sender: UIButton) { - + callBack?.sessionDone(res:["callResponse":"CallEnd"]) sessionDisconnect() } @@ -149,7 +162,6 @@ class ViewController: UIViewController { if (session != nil) { print("disconnecting....") session!.disconnect(nil) - callBack?.sessionDone(res:["callResponse":"CallEnd"]) dismiss(animated: true) return } @@ -248,7 +260,7 @@ class ViewController: UIViewController { seconds -= 1 //This will decrement(count down)the seconds. print(seconds) if seconds == 0 { - callApi() + getSessionStatus() } diff --git a/lib/models/livecare/session_status_model.dart b/lib/models/livecare/session_status_model.dart index ad9a1142..7e7a3e43 100644 --- a/lib/models/livecare/session_status_model.dart +++ b/lib/models/livecare/session_status_model.dart @@ -10,7 +10,7 @@ class SessionStatusModel { this.result, this.sessionStatus}); - SessionStatusModel.fromJson(Map json) { + SessionStatusModel.fromJson(Map json) { isAuthenticated = json['IsAuthenticated']; messageStatus = json['MessageStatus']; result = json['Result']; diff --git a/lib/util/VideoChannel.dart b/lib/util/VideoChannel.dart index 73b17930..9f4195af 100644 --- a/lib/util/VideoChannel.dart +++ b/lib/util/VideoChannel.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'dart:io' show Platform; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; @@ -30,9 +31,8 @@ class VideoChannel{ onCallEnd(); } else { - var asd = result['sessionStatus']; - var parsed = json.decode(result['sessionStatus']); - SessionStatusModel sessionStatusModel = SessionStatusModel.fromJson(parsed); + + SessionStatusModel sessionStatusModel = SessionStatusModel.fromJson(Platform.isIOS ?result['sessionStatus'] :json.decode(result['sessionStatus'])); callNotRespond(sessionStatusModel); }