Note: The code on this page is for tutorial purposes only. It shows how to call the SDK and is not production-ready: it leaves out error handling, threading and app lifecycle management. Review and adapt it before you use it in your app.
Overview
Creates the SDK object that every other API call goes through, using createRfidSdkApiInstance of srfidSdkFactory.
Details
Every RFID call in this tutorial is sent to one SDK object, called apiInstance in the samples. Create it with the createRfidSdkApiInstance method of srfidSdkFactory and keep a reference to it, for example as a property of your view controller or of a class that lives as long as the app. The object conforms to the srfidISdkApi protocol.
The factory and the protocol come from ZebraRfidSdkFramework, so import it where you use them:
#import <ZebraRfidSdkFramework/ZebraRfidSdkFramework.h>
Declare the reference and create the instance. The samples also use readerID, the ID of the reader you are working with. You set it when you connect (see Connect), and every later call passes it to the SDK.
id<srfidISdkApi> apiInstance;
int readerID;
- (void)createSdkInstance {
apiInstance = [srfidSdkFactory createRfidSdkApiInstance];
}
You can read the version of the SDK from the instance with srfidGetSdkVersion:
- (void)getSdkVersion {
NSLog(@"SDK version: %@", [apiInstance srfidGetSdkVersion]);
}
Right after creating the instance, set it up in this order. Each step has its own page:
- Register your delegate and subscribe for events (see Implement
srfidISdkApiDelegate). - Set the operation mode (see Set Operation Mode).
- Enable available readers detection (see Enable Available Readers Detection).
After this, the SDK reports readers through the delegate. To open a session with one of them, see Connect.