make things daynamic

merge-requests/147/head
Elham Rababah 5 years ago
parent 9ed9e3ed73
commit 6ea72f5ffa

@ -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

@ -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()
}

@ -10,7 +10,7 @@ class SessionStatusModel {
this.result,
this.sessionStatus});
SessionStatusModel.fromJson(Map<String, dynamic> json) {
SessionStatusModel.fromJson(Map<dynamic, dynamic> json) {
isAuthenticated = json['IsAuthenticated'];
messageStatus = json['MessageStatus'];
result = json['Result'];

@ -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);
}

Loading…
Cancel
Save