Nativescript plugin (IOS) for CardIO - Unable to call any function in the CARDIO library and are not exposed

423 Views Asked by At

We are trying to create a nativescript plugin(IOS) for CardIO www.card.io) CardIO(5.4.1):

  1. downloaded nativescript-plugin-seed (https://github.com/NathanWalker/nativescript-plugin-seed)
  2. Performed all pre-requesties for the seed.
  3. Added podFile in platform (pod 'CardIO', :git=> 'https://github.com/card-io/card.io-iOS-SDK.git')
  4. Modified CardIO.ios.ts to call the functions in the CardIO Library

The Pod is getting downloaded good. When we checked the XCODE project the Cardio pod is added and the library and *.h files are added GOOD.

When we run the project we are not able to call any of the functions in the CardIO library. We assume that none of the functions in the library is exposed for javascript.

JavaScript error:

file:///app/tns_modules/nativescript-cardio/cardio.js:3:57: JS ERROR ReferenceError: Can't find variable: CardIOPaymentViewController

Please find the code in 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);
    }
}
1

There are 1 best solutions below

2
Eddy Verbruggen On

I looked into this today and had to conclude the CardIO is not currently NativeScript compatible. It doesn't happen often but sometimes it does.

The good news is that you can take the assets of the Podfile and create a (in this case) static framework yourself that can be exposed to NativeScript just fine.

In this case though there's a few more challenges (three .a files instead of just one, for instance).

It's a bit too much (procedures and code) to explain here so I'd rather add some code to a GitHub repo and link to that from this issue.

Can you please mail me (eddyverbruggen at gmail dot com) if you want my assistance?