iOS:card.io使用

來源:互聯網
上載者:User

iOS:card.io使用

最近項目要用到一個功能:通過掃描銀行卡,擷取銀行卡號,在網上搜過後,選用了card.io這個SDK,過程如下:

(1)下載Card.io

Card.io是讓手機網路攝影機擷取信用卡的資訊,中間利用了OCR(光學字元辨識)的掃描技術返回結果,它還推出了SDK(軟體開發包),讓開發人員們可以把card.io添加到自己的應用當中。可以在https://github.com/paypal/PayPal-iOS-SDK下載最新的SDK

(2)添加到項目裡

1、將下載的SDK包裡名為CardIO的檔案拖到工程裡,在TARGETS-Build Phases - Link Binary With Librarys添加下面依賴庫

 

* AudioToolbox

* AVFoundation

* CoreGraphics

* CoreMedia

* CoreVideo

* Foundation

* MobileCoreServices

* OpenGLES

* QuartzCore

* Security

* UIKit

如果是xcode5或者更新的版本,只需要添加下面的庫

 

* AVFoundation

* AudioToolbox

* CoreMedia

* MobileCoreServices

並且保證Build Settings裡面這兩項都是YES:

 

* Enable Modules (C and Objective-C)

* Link Frameworks Automatically



2、在TARGETS-Build Settings添加 -lc++到Other Linker Flags
(3)使用

我是把它作為一個viewController類使用

代碼:

匯入

#import "CardIO.h"

#import "CardIOPaymentViewControllerDelegate.h"



 

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

[CardIOUtilities preload];

}

//開始掃描

 

- (IBAction)scanCard:(id)sender

{

CardIOPaymentViewController *scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate:self];

[self presentViewController:scanViewController animated:YES completion:nil];

}

下面是代理方法

 

//取消掃描

- (void)userDidCancelPaymentViewController:(CardIOPaymentViewController *)scanViewController

{

NSLog(@"User canceled payment info");

// Handle user cancellation here...

[scanViewController dismissViewControllerAnimated:YES completion:nil];

}

//掃描完成

-(void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)scanViewController

{

//掃描結果

NSLog(@"Received card info. Number: %@, expiry: %02i/%i, cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv);

// Use the card info...

[scanViewController dismissViewControllerAnimated:YES completion:nil];

}





相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.