你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS:card.io使用

iOS:card.io使用

編輯:IOS開發綜合

最近項目要用到一個功能:通過掃描銀行卡,獲取銀行卡號,在網上搜過後,選用了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];

}





  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved