Closed fuadwaheed closed 3 years ago
That issue is in presenting the controller from your side
You have to put your code in Async thread while you are presenting Payment controller. Yo can refer demo for this project.
For Example:
DispatchQueue.main.async { let podBundle = Bundle(for: SelectPaymentMethodVC.self) let storyboard = UIStoryboard(name: "mainStoryboard", bundle: podBundle) let vc = storyboard.instantiateViewController(withIdentifier: "SelectPaymentMethodVC") as! SelectPaymentMethodVC vc.delegate = self vc.isSandbox = true vc.strAccessToken = strAccessToken vc.amount = self.TotalValue() vc.arrProductDetails = self.arrProduct let navigationController = UINavigationController(rootViewController: vc) navigationController.modalPresentationStyle = .overCurrentContext self.present(navigationController, animated: true, completion: nil) }
I am already following the demo code i added podBundle still its very laggy and sometimes crashes and it still shows
Main Thread Checker: UI API called on a background thread: -[UIApplication keyWindow]
DispatchQueue.main.async {
let podBundle = Bundle(for: SelectPaymentMethodVC.self)
let storyboard = UIStoryboard(name: "mainStoryboard", bundle: podBundle)
if let vc = storyboard.instantiateViewController(withIdentifier: "SelectPaymentMethodVC") as? SelectPaymentMethodVC
{
vc.delegate = self
vc.isSandbox = false
vc.strAccessToken = Cache.extractString("accessToken") ?? ""
vc.amount = Int(1)
vc.arrProductDetails = arrProduct
vc.modalPresentationStyle = .overCurrentContext
let navigationController = UINavigationController(rootViewController: vc)
self.present(navigationController, animated: true, completion: nil)
}
}
Application is getting crashed always when i present the sadad payment controller, the reason console shows is
"'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread."
as sadad provides framework i cannot edit the code of this where main thread is accessed in background thread. Kindly help me to resolve this issue
@HirenHRathod @Nivsangani113 @SadadDeveloper