Result Code
Code | Message |
---|---|
1 | Success, get more infomation with vid |
1001 | Network Error, check network states |
1002 | Server Error |
1005 | VID Not Found |
2003 | NFC Tag Lost, if the nfc tag leaves the field or there is an I/O failure, try again |
2005 | NFC Auth Error with the wrong chip |
3001 | NFC not available on this device |
3005 | NFC tag Copied |
3006 | Product infomation not published for the vid |
3007 | NFC Session error, timeout . Please retry |
3008 | NFC Session invalidated by user. Please retry |
4001 | NFC tag status opened |
4100 | NFC tag status detected as opened && copied |
9012 | VID No Permission, Please your permisstion |
100003 | VID APP Signature Error |
100004 | VID APP Certification Error |
100006 | VID VerifyID Not Exist, Check your verify ID. |
Quick Start
/// 1. register SDK
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
VeChainNFCSDK.registerSDK(appid)
VeChainNFCSDK.setDelegate(self)
return true
}
}
extension AppDelegate: VeChainNFCSDKDelegate {
// local sign
func sign(_ challengeId: String, signNotifier: SignNotifier) {
let certString = "your cert string"
let privateKey = "your cert private key"
let signature = CertUtils.getSignature(certString, certKey: privateKey, challengeId: challengeId)
signNotifier.onSignResult(signature: signature)
}
}
/// 2. start verify in your view controllers
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
VeChainNFCSDK.verifyTags { (result) in
if result.code == VerifyResultCode.success.rawValue {
/// verify success
} else {
/// verify fail
}
}
}
}
API Reference
Register
Start from registering your sdk
/// Call this method when the application is launched
/// @param verifyId is got from VeChain Toolchain Portal/Developer Center.
public static func registerSDK(_ verifyId: String)
Set delegate
Delegate is the implementation of VeChainNFCSDKDelegate interface
We recommend you to use AppDelegate to implement the VeChainNFCSDKDelegate.
public static func setDelegate(_ delegate: VeChainNFCSDK.VeChainNFCSDKDelegate)
Implement the delegate function
// Notice: you have two options to get the signature
// Option1: get the signature from remote server, please see: Appendix A: FAQ How to Sign ChallengeID
// Option2: get the signature from local, please see: Appendix A: FAQ How to Sign ChallengeID
func sign(_ challengeId: String, signNotifier: SignNotifier)
Verify NFC Tags
// This function will use iOS CoreNFC module to identify nfc tags and verify the tags.
// @param completion callback with verifyResult contains result code, vid, url(if tag contains a url), vidAccessToken
public static func verifyTags(_ completion:
@escaping VeChainNFCSDK.VeChainVerifyCompletionBlock)
Verify Qrcode
// Use this function to verify the qrcode.
// @param qrcode the qrcode string.
// @param completion callback with verifyResult contains result code, vid, url(if containing a url)
public static func verifyQrcode(_ qrcode: String, completion:
@escaping VeChainNFCSDK.VeChainVerifyCompletionBlock)
Get Version
// Get SDK Version
public static func getVersion() -> String
Comments
0 comments
Please sign in to leave a comment.