iOS
Package details
The package consists of a versioned zip file containing:
Shell1Package/2 SDK/3 iOS/4 BChainSDK-release-X.xcframework5 BChain - Sample - X
Package installation
The installation process consists of unzipping the package in a dedicated folder, copying the framework file in a project directory, and then adding the framework with XCode:
The SDK is now ready to be used.
SDK requirements
Minimal OS Version: iOS 13.3.
The SDK requires to have a secure enclave available (software & hardware) on the phone with the algorithm eciesEncryptionCofactorVariableIVX963SHA256AESGCM
if this requirements is not matched the SDK will not perform any action on the card.
NFC settings
The SDK use NFC to communicate with the card and a specific configuration is required to have the NFC working on the phone.
First, you need to create in https://developer.apple.com/account/ :
- A device(s) ID: device(s) who will use the application,
- An application identifier and enable the NFC capabilities,
- A provisioning profile that include all the identifiers created.
Then you need to setup the application project:
- Select the provisioning profile created in project settings,
- Add NFC capability to the project.
Update .plist file to add the applet AID (A0000000770306000A00000100020001): Add the “ISO7816 application identifier for NFC Tag Reader Session” section or add the code
XML1<!-- Plist file setup – setup card AID -->2<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>3<array>4 <string>12FC</string>5</array>6<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>7<array>8 <string>A0000000770306000A00000100020001</string>9</array>
Update .plist file to add the applet AID (A0000000770306000A00000100020001): Add the “ISO7816 application identifier for NFC Tag Reader Session” section or add the code
XML1<!-- Plist file – setup default card reader message -->2<key>NFCReade rUsageDescript ion</key>3<string>Put the card on the NFC sensor</string>
Update the .entitlements file to enable NFC:
XML1<!-- Entitlements file – setup NFC -->2<key>com.apple.developer.nfc.readersession.formats</key>3<array>4 <string>TAG</string>5</array>
Dependencies
No dependencies are required to use this SDK.
The SDK allows changing the AID used by the SDK by updating the static member SDKSettings.appletAid
:
Swift1SDKSettings.appletAid = "Custom AID value"
The default value is A0000000770306000A00000100020001
.
SDK usage
The iOS SDK abstract the card communication and key functionalities, this SDK will use the NFC to communicate with the card, be sure that the application is ready and setup before continuing.
BChainManager
BChainManager is the entry point of the library and contains all actions to perform on the card. This class requires an ICommunication
object. To obtain an ICommunication
object you have to use the class NFCHelper
.
All methods are synchronous.
Usage sample:
Swift1<!-- BChainManager usage sample -->2let pin = "1234"3let communication = ... // Get communication from NFCHelper4let manager = BchainManager(communication: communication) // Load manager5try manager.connect() // Connect to the card6try manager.getCardStatus() // Execute actions
NFCHelper & ICommunication
NFCHelper
is a helper class that will handle the NFC functionalities and help to obtain an ICommunication
object for the NFC (NFCCommunication), this class will be required by the SDK manager to communicate with the card.
NFCHelper
methods:
Method name | Description |
---|---|
public static func getInstance() -> NFCHelper | Get an instance of the helper class |
public func startCardDetector(_ callback: CardDetectorCallback) | Open the NFC popup and start the NFC card detector, if a card is detected the parameter callback method onCardDetected(_communication: ICommunication) will be called |
public func stopCardDetector() | Stop the NFC card detector |
public func isCardDetected() -> Bool | Indicate if a card is detected or not |
public static func isNFCAvailable() -> Bool | Indicate if the NFC functionalities is enabled on the phone |
Usage sample:
Swift1// NFCHelper usage sample2Override func viewDidLoad() {3 super.viewDidLoad()4 NFCHelper.getInstance().startDetector(self) // Open the NFC popup5}67Public func onCardDetected(_ communication: ICommunication) {8// Card detected. Use communication to perform action...9}
Methods details
Find all method list and details here.