Created
November 20, 2022 07:47
-
-
Save definev/dc57dd3f5a06bdc0461cfb11746786c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Flutter | |
#if !targetEnvironment(simulator) | |
import FinalSDK | |
@UIApplicationMain | |
@objc class AppDelegate: FlutterAppDelegate, ICEkycCameraDelegate { | |
var methodChannel: FlutterResult? | |
override func application( | |
_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
) -> Bool { | |
// Key test on side Product | |
// input key | |
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController | |
let channel = FlutterMethodChannel(name: "hapi_ekyc", | |
binaryMessenger: controller.binaryMessenger) | |
channel.setMethodCallHandler({ | |
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | |
// Note: this method is invoked on the UI thread. | |
// Handle battery messages. | |
self.methodChannel = result | |
if call.method == "startEKYC" {// method truy van tu fluuter | |
DispatchQueue.main.async { | |
if let args = call.arguments as? Dictionary<String, Any> { | |
let language = args["language"] as? String | |
let tokenId = args["tokenId"] as? String | |
let tokenKey = args["tokenKey"] as? String | |
let accessToken = args["accessToken"] as? String | |
// please check the "as" above - wasn't able to test | |
// handle the method | |
SaveData.shared().sdTokenId = tokenId ?? "d24f2ace-e494-4c06-e053-63199f0a6f97" | |
SaveData.shared().sdTokenKey = tokenKey ?? "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAI+waDo0v7oMdgDTPPjnfnn7MMwHvt4rCw0nyS0ft5LwCHceDcJ60Ndv+m/zWeLMM3kEiZdzhmm/T3FdhGK5qHUCAwEAAQ==" | |
SaveData.shared().sdAuthorization = accessToken ?? "bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhYTVlNGU2OS01NGRmLTExZWMtYjMzOS0xZjczYjNlMTAwYTciLCJhdWQiOlsicmVzdHNlcnZpY2UiXSwidXNlcl9uYW1lIjoiaHV5Lm5ndXllbkBoYXBpLnNvbHV0aW9ucyIsInNjb3BlIjpbInJlYWQiXSwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3QiLCJuYW1lIjoiaHV5Lm5ndXllbkBoYXBpLnNvbHV0aW9ucyIsInV1aWRfYWNjb3VudCI6ImFhNWU0ZTY5LTU0ZGYtMTFlYy1iMzM5LTFmNzNiM2UxMDBhNyIsImF1dGhvcml0aWVzIjpbIlVTRVIiXSwianRpIjoiNGRmNzk4ZmYtNjgwNy00ZjM0LWFhMWItN2M4ZTNmOWEzYzkyIiwiY2xpZW50X2lkIjoiYWRtaW5hcHAifQ.pIwIWo7nVGZqkJcqyqR3CcMSzU3hI09prOd9jgFW9e2uZRYMLcABjmOX-iRrv-odCtBgFL2M9mBmUjB07tVaO13FvoFJyxj9Lxz9C_JEeM5zgvpMDkNeMKf1fFWHspkuRchqWsPNdMndR1IbpG5H-_3MeqHbjWV1Pmp7QAGcYFcL-yM5mJCnVSGgT7c3jGFUBeQy96wtfaXqZT2J-br0IVWjWDg1qgmpzKFA3bVu92xgQClQfGx9fUuxI5E5lWJo02_tN0GxMIR1bv_Z758O3SolIYScOLAxbz9X1Vb0RRvtKjUmKwL8Ut7qhdAb2jX0GhGz-YprkCdPrdKkQB2ayA" | |
self.showNormal(controller, language: language!) | |
} else { | |
self.methodChannel!(nil) | |
} | |
} | |
} else { | |
DispatchQueue.main.async { | |
// Call the desired channel message here. | |
self.methodChannel!(FlutterMethodNotImplemented) // tra ve loi cho fluuter hieu | |
} | |
} | |
}) | |
GeneratedPluginRegistrant.register(with: self) | |
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | |
} | |
func showNormal(_ controller:UIViewController, language: String) { | |
let objCamera = ICEkycCameraRouter.createModule() as! ICEkycCameraViewController | |
objCamera.isVersion = Pro | |
objCamera.flowType = full | |
objCamera.isType = cmt | |
objCamera.cameraDelegate = self | |
objCamera.stepNow = stepFront | |
// objCamera.arrayItemPostCode = [] as Array<PostCodeType> | |
objCamera.unitCustomer = "test1" | |
objCamera.resourceCustomer = "VNPT" | |
objCamera.challengeCode = "INNOVATIONCENTER" | |
objCamera.isShowResult = false | |
objCamera.isShowHelp = true | |
objCamera.isShowTrademark = false | |
objCamera.isCheckLivenessCard = true | |
objCamera.isCheckMaskFace = true | |
objCamera.isAddFace = true | |
objCamera.isCheckLivenessFace = true | |
objCamera.languageApplication = language | |
objCamera.isValidatePostcode = true | |
objCamera.modalPresentationStyle = .fullScreen | |
objCamera.modalTransitionStyle = .coverVertical | |
controller.present(objCamera, animated: true, completion: nil) | |
} | |
func getResult() { | |
self.methodChannel!(SaveData.shared().jsonInfo) | |
} | |
func closeSDK(_ type:ScreenType) { | |
if (type.rawValue == 9) { | |
return | |
} | |
self.methodChannel!(nil) | |
} | |
} | |
#else | |
@UIApplicationMain | |
@objc class AppDelegate: FlutterAppDelegate { | |
var methodChannel: FlutterResult? | |
override func application( | |
_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
) -> Bool { | |
let channel = FlutterMethodChannel(name: "hapi_ekyc", | |
binaryMessenger: controller.binaryMessenger) | |
channel.setMethodCallHandler({ | |
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | |
// Note: this method is invoked on the UI thread. | |
// Handle battery messages. | |
self.methodChannel = result | |
if call.method == "startEKYC" {// method truy van tu fluuter | |
DispatchQueue.main.async { | |
if let args = call.arguments as? Dictionary<String, Any> { | |
let language = args["language"] as? String | |
let tokenId = args["tokenId"] as? String | |
let tokenKey = args["tokenKey"] as? String | |
let accessToken = args["accessToken"] as? String | |
// please check the "as" above - wasn't able to test | |
// handle the method | |
self.methodChannel!([ | |
"tokenId": tokenId, | |
"tokenKey": tokenKey, | |
"accessToken": accessToken | |
]) | |
} | |
} | |
} else { | |
DispatchQueue.main.async { | |
// Call the desired channel message here. | |
self.methodChannel!(FlutterMethodNotImplemented) // tra ve loi cho fluuter hieu | |
} | |
} | |
}) | |
GeneratedPluginRegistrant.register(with: self) | |
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment