Overview
Registers an object that conforms to the ISbtSdkApiDelegate protocol to receive callbacks from the barcode SDK, using sbtSetDelegate.
Details
Objective C protocol which defines SDK callbacks interface. Registration of a particular object which conforms to ISbtSdkApiDelegate protocol is required to receive particular from the SDK. SDK callback interface is defined by ISbtSdkApiDelegate Objective C protocol. Registration of a particular object which conforms to ISbtSdkApiDelegate protocol is required to receive particular notifications from Zebra Bluetooth Scanner iOS SDK.
BarcodeViewController.h file.
#import <UIKit/UIKit.h>
#import "SbtSdkFactory.h"
/// Responsible for barcode sdk events and action
@interface BarcodeViewController : UIViewController<ISbtSdkApiDelegate> {
}
@end
BarcodeViewController.m file.
#import "BarcodeViewController.h"
/// Responsible for barcode sdk events and action
@interface BarcodeViewController ()
@end
@implementation BarcodeViewController
#pragma mark - Life Cycle Methods
- (void)viewDidLoad {
[super viewDidLoad];
[sdkApi sbtSetDelegate:self];
}
/// The barcode event
/// @param barcodeData The barcode data
/// @param barcodeType The barcode type
/// @param scannerID The scanner id
- (void)sbtEventBarcode:(NSString *)barcodeData barcodeType:(int)barcodeType fromScanner:(int)scannerID {
NSLog(@"Barcode Event: data event, %@",barcodeData);
}
/// The barcode event data
/// @param barcodeData The barcode data
/// @param barcodeType The barcode type
/// @param scannerID The scanner id
- (void)sbtEventBarcodeData:(NSData *)barcodeData barcodeType:(int)barcodeType fromScanner:(int)scannerID {
NSData *decodeData = [[NSData alloc] initWithData:barcodeData];
NSString *decodeDataString = [[NSString alloc] initWithBytes:((unsigned char*)[decodeData bytes]) length:([decodeData length]) encoding:NSUTF8StringEncoding];
NSLog(@"Barcode Event : %@",decodeDataString);
dispatch_async(dispatch_get_main_queue(),^{
self->textView_barcode_data.text = decodeDataString;
});
}
/// The device connected event
/// @param activeScanner The connected scanner object
- (void)sbtEventCommunicationSessionEstablished:(SbtScannerInfo *)activeScanner {
NSLog(@"Device has connected, Device name :%@",[activeScanner getScannerName]);
}
/// The device disconnected event
/// @param scannerID The scanner id
- (void)sbtEventCommunicationSessionTerminated:(int)scannerID {
NSLog(@"Device has Disconnected, Device ID %d",scannerID);
}
/// The firmware update event
/// @param fwUpdateEventObj firmware update event object
- (void)sbtEventFirmwareUpdate:(FirmwareUpdateEvent *)fwUpdateEventObj {
NSLog(@"Firmware update event - Max record : %d",fwUpdateEventObj.maxRecords);
NSLog(@"Firmware update event - Current record : %d",fwUpdateEventObj.currentRecord);
NSLog(@"Firmware update event - Current Status : %d",fwUpdateEventObj.status);
}
/// The image event
/// @param imageData The image data
/// @param scannerID The scanner id
- (void)sbtEventImage:(NSData *)imageData fromScanner:(int)scannerID {
NSLog(@"Image event");
}
/// The device appear event
/// @param availableScanner The scanner object
- (void)sbtEventScannerAppeared:(SbtScannerInfo *)availableScanner {
NSLog(@"Device has appeared, Device name %@",[availableScanner getScannerName]);
}
/// The scanner disappear event
/// @param scannerID The scanner id
- (void)sbtEventScannerDisappeared:(int)scannerID {
NSLog(@"Device disappeared");
}
/// The video event
/// @param videoFrame The video data
/// @param scannerID The scanner id
- (void)sbtEventVideo:(NSData *)videoFrame fromScanner:(int)scannerID {
NSLog(@"The video event");
}
@end