I am developing a native module to integrate payments.
After debugging with xcode and using symbolic breakpoints I found the source of the issue, but I want to understand why this is happening, and how to fix the issue.
I use a UIViewController
to present this modal, but the type of the view controller is RCTModalHostViewController
, because the UI library I am using (UI Kitten) is doing somthing to change the view controller’s type.
When I remove UI Kitten, the view controller type returns UIViewController
again, and the modal does not disappear.
How do I get the instance of the view controller?
I use this method RCTPresentedViewController()
from this header <React/RCTUtils.h>
.
The relevant part of the code is here:
internal class OppwaHandler: NSObject, UINavigationControllerDelegate, OPPThreeDSEventListener, PKPaymentAuthorizationViewControllerDelegate {
// constants
let viewController = RCTPresentedViewController()
// ... some irrelevant code
public func onApplePay(params: ApplePayParams) -> String {
// ... some irrelevant code
if let rootViewController = self.viewController {
if let vc = PKPaymentAuthorizationViewController(paymentRequest: request) as PKPaymentAuthorizationViewController? {
vc.delegate = self
DispatchQueue.main.async {
rootViewController.present(vc, animated: true, completion: nil)
}
return "Ok. reached end of ok logic"
} else {
return "Apple Pay not supported."
}
}else{
return "Not showing view controller"
}
When using UI KItten the type of rootViewController
is RCTModalHostViewController
, but when I remove UI Kitten its type is UIViewController
and the modal does not disappear.
Versions:
- Expo: 50.0.17
- React Native: 0.73.6
- UI Kitten: 5.1.2
General info:
- The modal in question is Apple Pay window.
- I am integrating Apply Pay with Oppwa.