Recently, because the company needs a scan card to obtain the card number of the function of the Internet to find a lot of relevant information, completely scan the bank card to obtain the card number information is very expensive, and just authorization, here we retreat and seek to find a third-party framework can scan credit card, to share the big guy, Can only scan credit card ... o.0.
The frame's name is cardio.
Here the main show you how to integrate, you crossing can have to pay attention to! My Xcode is version 7.1, first of all pull the framework into its own project, and then in Targets-build Phases-link binary with libraries inside the following several frameworks are added
Accelerate.framework
Mobilecoreservices.framework
Coremedia.framework
Audiotoolbox.framework
Avfoundation.framework
Add-OBJC and-lc++ in the Targets-build settings-other Linker flags and import the header file #import "CardIO.h" and #import in the VC we need to call CardIOPaymentViewControllerDelegate.h "plus agent Cardiopaymentviewcontrollerdelegate
And then the method of implementation
OC version
- (void)viewdidload {
[Super viewdidload];
[cardioutilities preload];
}
Start Call scan
- (ibaction)begin:(ID)sender {
cardiopaymentviewcontroller *scanviewcontroller = [[ Cardiopaymentviewcontroller Alloc] initwithpaymentdelegate: Self];
[self presentviewcontroller: Scanviewcontroller animated: YES Completion: Nil];
}
Cancel Scan
- (void)userdidcancelpaymentviewcontroller:(cardiopaymentviewcontroller *)scanviewcontroller
{
[scanviewcontroller dismissviewcontrolleranimated: YES completion: nil];
}
Scan complete
-(void)userdidprovidecreditcardinfo:(cardiocreditcardinfo *) info inpaymentviewcontroller:(cardiopaymentviewcontroller *) Scanviewcontroller
{
//Scan results
NSLog(@ "Received card info. Number:%<a href= "http://www.jobbole.com/members/uz441800" >@,</a> expiry:%02i/%i, CVV:%@. " , Info.redactedcardnumber, Info.expirymonth, Info.expiryyear, INFO.CVV);
[scanviewcontroller dismissviewcontrolleranimated: YES completion: nil];
}
Swift version
Import UIKit
Class Viewcontroller: Uiviewcontroller, cardiopaymentviewcontrollerdelegate {
@Iboutlet weak var resultlabel: UILabel!
Override func Viewdidload() {
Super. Viewdidload()
cardioutilities. Preload()
}
Start Call scan
@ibaction func scancard(sender: anyobject) {
let cardiovc = cardiopaymentviewcontroller(paymentdelegate: Self)
CARDIOVC. Modalpresentationstyle = . Formsheet
Presentviewcontroller(cardiovc, animated: True, completion: nil)
}
Cancel Scan
Func userdidcancelpaymentviewcontroller(paymentviewcontroller: Cardiopaymentviewcontroller!) {
ResultLabel. Text = "User canceled"
paymentviewcontroller?. dismissviewcontrolleranimated(true, completion: nil)
}
Scan complete
Func userdidprovidecreditcardinfo(cardinfo: Cardiocreditcardinfo!, Inpaymentviewcontroller paymentviewcontroller: Cardiopaymentviewcontroller!) {
if let info = cardinfo {
let str = nsstring(format: "Received card info.\\\\n Number:%@\\\\n expiry:%02lu/%lu\\ \\n CVV:%@. " , info. Redactedcardnumber, info. Expirymonth, info. Expiryyear, info. CVV)
ResultLabel. Text = str as String
}
paymentviewcontroller?. dismissviewcontrolleranimated(true, completion:nil)
}
}
This is done, the foreigner package is still very good, I hope to find a better way to scan the bank card more useful third-party.
The final effect, the recognition is very accurate OH
OCR optical recognition debit card and credit cards developed by iOS