我们正在尝试为 CardIO www.card.io) CardIO(5.4.1) 创建一个 nativescript 插件(IOS):
- 下载了 nativescript-plugin-seed ( https://github.com/NathanWalker/nativescript-plugin-seed )
- 执行种子的所有预请求。
- 在平台中添加了 podFile (pod 'CardIO', :git=> ' https://github.com/card-io/card.io-iOS-SDK.git ')
- 修改 CardIO.ios.ts 以调用 CardIO 库中的函数
Pod 下载良好。当我们检查 XCODE 项目时,添加了 Cardio pod,并添加了库和 *.h 文件。
当我们运行项目时,我们无法调用 CardIO 库中的任何函数。我们假设库中的所有函数都没有为 javascript 公开。
JavaScript 错误:
file:///app/tns_modules/nativescript-cardio/cardio.js:3:57:JS 错误 ReferenceError:找不到变量:CardIOPaymentViewController
请在 heart.ios.ts 中找到代码
export var scanCardClicked = function () {
// var CardIOPaymentViewController=new CardIOPaymentViewController();
let scanViewController = CardIOPaymentViewController.alloc().initWithPaymentDelegate(this);
scanViewController.modalPresentationStyle = UIModalPresentationFormSheet;
this.presentViewControllerAnimatedCompletion(scanViewController, 1, null);
}
class CardIOPaymentViewControllerDelegateImpl extends NSObject implements CardIOPaymentViewControllerDelegate {
userDidProvideCreditCardInfoInPaymentViewController(info: CardIOCreditCardInfo, paymentViewController: CardIOPaymentViewController)
{this.dismissViewControllerAnimatedCompletion(1, null);
//this.infoLabel.test = "Received Card: " + info.redactedCardNumber + "Expiry:" + info.expiryMonth + "/" + info.expiryYear + "CVV:" + info.cvv;
}
userDidCancelPaymentViewController(paymentViewController: CardIOPaymentViewController)
{
this.dismissViewControllerAnimatedCompletion(1, null);
}
}