Credit card number and expiration date can be scanned with your phone camera, saving you from having to key in your digits manually.
Tap the camera icon in the card number field to scan the card.
For the first time the app will request access to the camera.
Then position your card and it will scan card number and expiration date.
You will still need to manually enter card holder and CVV code.
Integration
To enable this feature add the following framework to the project.
OPPWAMobile-CardIO.framework
Drap and drop OPPWAMobile-CardIO.framework to the "Frameworks" folder of your project. Make sure "Copy items if needed" is checked.
Embed the framework
Go to the app target’s General configuration page.
Add the framework target to the Embedded Binaries section by clicking the Add icon.
Select OPPWAMobile-CardIO.framework from the list of binaries.
Add a Run Script
The framework contains a build for both the simulator (i386, x86_64) and the actual devices (ARM). As it is not permitted to submit a binary for an unsupported architecture to App Store, you have to add script that "manually" removes unused architectures from the final binary.
Go to the app target’s Build Phases tab.
In Xcode menu, select Editor > Add Build Phase > Add Run Script Build Phase. You should now see a Run Script section in your Build Phase options.
Important: "Run Script" phase should be put after "Embed Framework" phase. You can reoder build phases by dragging them using your mouse.
Set it to use /bin/sh and check the Run script only when installing option.
Enter the following script:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name 'OPPWAMobile*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
Review your Build Phases:
OPPWAMobile-CardIO.framework is added to the "Link Binary With Libraries" and "Embed Frameworks" phases.
"Run Script" phase is put after the "Embed Frameworks" phase and contains our script.
Provide usage descriptions in your app's Info.plist
NSCameraUsageDescription - set the value to be a string describing why your app needs to use the camera (e.g. "To scan credit cards."). This string will be displayed when the app initially requests permission to access the camera.
NSPhotoLibraryUsageDescription - Card.IO never asks for this key actually, however it's needed when uploading to App Store. Set any non-empty string, e.g. duplicate NSCameraUsageDescription description.
To enable this feature add the following dependency to your build.gradle: