IOS: card. io usage
Recently, a function is used to scan a bank card and obtain the bank card number. After searching the Internet, the SDK card. io is used. The process is as follows:
(1) download Card. io
Card. i/O allows the mobile phone camera to obtain credit card information, and uses OCR (Optical Character Recognition) Scanning Technology to return the results. It also introduces the SDK (software development kit ), let developers put the card. i/O is added to your own application. You can download the latest SDK at https://github.com/paypal/paypal-ios-sdk.
(2) Add to project
1. Drag the downloaded CardIO file in the SDK package to the project and add the following dependent libraries in TARGETS-Build Phases-Link Binary With Librarys.
* AudioToolbox
* AVFoundation
* CoreGraphics
* CoreMedia
* CoreVideo
* Foundation
* MobileCoreServices
* OpenGLES
* QuartzCore
* Security
* UIKit
If it is xcode5 or an updated version, you only need to add the following Library
* AVFoundation
* AudioToolbox
* CoreMedia
* MobileCoreServices
Make sure that the two items in Build Settings are YES:
* Enable Modules (C and Objective-C)
* Link Frameworks Automatically
2. Add-lc ++ to Other Linker Flags in TARGETS-Build Settings.
(3) Use
I use it as a viewController class.
Code:
Import
# Import "CardIO. h"
# Import "CardIOPaymentViewControllerDelegate. h"
-(Void) viewWillAppear :( BOOL) animated {
[Super viewWillAppear: animated];
[CardIOUtilities preload];
}
// Start scanning
-(IBAction) scanCard :( id) sender
{
CardIOPaymentViewController * scanViewController = [[CardIOPaymentViewController alloc] initWithPaymentDelegate: self];
[Self presentViewController: scanViewController animated: YES completion: nil];
}
The following is the proxy method
// Cancel the scan
-(Void) userDidCancelPaymentViewController :( CardIOPaymentViewController *) scanViewController
{
NSLog (@ "User canceled payment info ");
// Handle user cancellation here...
[ScanViewController dismissViewControllerAnimated: YES completion: nil];
}
// Scan completed
-(Void) userDidProvideCreditCardInfo :( CardIOCreditCardInfo *) info inPaymentViewController :( CardIOPaymentViewController *) scanViewController
{
// Scan result
NSLog (@ "Your Ed card info. number: % @, expiry: % 02i/% I, cvv: % @. ", info. redactedCardNumber, info. expiryMonth, info. expiryYear, info. cvv );
// Use the card info...
[ScanViewController dismissViewControllerAnimated: YES completion: nil];
}