我正在尝试在 React Native - Adyen中集成本机支付库。
我有基本的桥接通信,从用 Swift 编写的 JS 本机方法执行就可以了,等等。每当我想显示库的“插入式”视图(即 UIViewController)时,我都会遇到问题。
AdyenModule.swift
import Foundation
import Adyen
@objc(AdyenModule)
class AdyenModule: RCTEventEmitter {
// ... other methods that work just fine
@objc func showDropInComponent() {
// ...creating configuration, getting payment methods etc.
DispatchQueue.main.async {
let dropInComponent = DropInComponent(paymentMethods: paymentMethods, paymentMethodsConfiguration: configuration);
dropInComponent.delegate = self;
(UIApplication.shared.delegate?.window??.rootViewController)!.present(dropInComponent.viewController, animated: true);
}
}
}
showDropInComponent
我从 JavaScript调用该方法。它被执行并且本机代码显示 Adyen 的视图(如下所示)。这个视图似乎对触摸做出反应,但只是视觉上的。单击 X 按钮或付款方式除了视觉效果外,没有任何作用。下面的屏幕截图显示了按下第一种付款方式的时刻。
我假设由于某种原因视图没有得到事件。我几乎可以肯定我显示不正确,需要一些特殊的 React Native“魔法”才能使其工作......我将不胜感激任何帮助!