ios - CardIO 的 Nativescript 插件 (IOS) - 无法调用 CARDIO 库中的任何函数且未公开

标签 ios cocoapods angular2-nativescript cardio

我们正在尝试为 CardIO 创建一个 nativescript 插件(IOS)www.card.io) CardIO(5.4.1):

  1. 已下载 nativescript-plugin-seed ( https://github.com/NathanWalker/nativescript-plugin-seed )
  2. 为种子执行了所有预先请求。
  3. 在平台中添加了 podFile (pod 'CardIO', :git=> ' https://github.com/card-io/card.io-iOS-SDK.git ')
  4. 修改 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/

相关文章:

ios - 如何访问存储在 UICollectionViewController 中的 Collection View Cell 中的变量

iphone - CGPDFDocumentCreateWithURL 内存使用

ios - 单例 VS 静态(类)变量

ios - 从 Swift 2.3 (xCode 7) 迁移 --> Swift 4(xCode 9) + 更新 Cocoapods

ios - Cocoapods:如何使用最新的 Swift 版本创建一个 pod?

angular - 如何将 angular 2 组件创建到 Nativescript 应用程序中?

ios - 如何在 Nativescript IOS Webview 上更改用户代理或设置为桌面模式

javascript - NativeScript 插件在外部 ng2 项目(不是演示)中崩溃

ios - 无法启动模拟器

ios - 使用一个目标中的框架作为本地另一目标中的 Pod