|
|
|
|
@ -151,35 +151,55 @@ class PenguinView: NSObject, FlutterPlatformView
|
|
|
|
|
print("====== after present onPenNavSuccess =========")
|
|
|
|
|
|
|
|
|
|
guard let config = self.model else {
|
|
|
|
|
print("Error: Config Model is nil")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
print("Error: Config Model is nil")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guard let clinicID = self.model?.clinicID,
|
|
|
|
|
let clientID = self.model?.clientID, !clientID.isEmpty else {
|
|
|
|
|
print("Error: Config Client ID is nil or empty")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let navigator = PenguinNavigator(config: config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PenNavUIManager.shared.getToken(clientID: config.clientID, clientKey: config.clientKey) { [weak self] token, error in
|
|
|
|
|
if let error = error {
|
|
|
|
|
let errorMessage = "Token error while getting the for Navigate to method"
|
|
|
|
|
// completion(false, "Failed to get token: \(errorMessage)")
|
|
|
|
|
print("Failed to get token: \(errorMessage)")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard let token = token else {
|
|
|
|
|
// completion(false, "Token is nil")
|
|
|
|
|
print("Token is nil")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
print("Token Generated")
|
|
|
|
|
print(token);
|
|
|
|
|
PenNavUIManager.shared.setToken(token: token)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self?.handleNavigation(clinicID: clinicID, token: token) { success, errorMessage in
|
|
|
|
|
if success {
|
|
|
|
|
print("Navigation successful")
|
|
|
|
|
} else {
|
|
|
|
|
print("Navigation failed: \(errorMessage ?? "Unknown error")")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print("====== after Token onPenNavSuccess =========")
|
|
|
|
|
}
|
|
|
|
|
PenNavUIManager.shared.navigate(to: config.clinicID)
|
|
|
|
|
print("====== after Token onPenNavSuccess =========")
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func handleNavigation(clinicID: String, token: String, completion: @escaping (Bool, String?) -> Void) {
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
PenNavUIManager.shared.setToken(token: token)
|
|
|
|
|
PenNavUIManager.shared.navigate(to: clinicID)
|
|
|
|
|
completion(true,nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|