我们正在尝试为 CardIO 创建一个 nativescript 插件(IOS)www.card.io) CardIO(5.4.1):
- 已下载 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 ERROR ReferenceError: Can't find variable: CardIOPaymentViewController
请在 cardio.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);
}
}
最佳答案
我今天调查了一下,不得不得出结论,CardIO 当前不兼容 NativeScript。它不会经常发生,但有时会发生。
好消息是您可以获取 Podfile 的 Assets 并自己创建一个(在本例中)可以很好地暴露给 NativeScript 的静态框架。
在这种情况下,尽管还有一些挑战(例如,三个 .a 文件而不是一个)。
这里解释的(过程和代码)有点太多,所以我宁愿将一些代码添加到 GitHub 存储库并从这个问题链接到它。
如果需要我的帮助,可以发邮件给我(eddyverbruggen at gmail dot com)吗?
关于ios - CardIO 的 Nativescript 插件 (IOS) - 无法调用 CARDIO 库中的任何函数且未公开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43610017/