Notifications
All NSNotification constants provided by the Aila SDK.
Overview
The SDK posts notifications to the default NSNotificationCenter for various events. Subscribe to these notifications to react to hardware changes, scan events, and other system events.
AilaMobileImagerStateChangedNotification
Since 3.0.0Posted when the scanning state is changed by depressing the dedicated scan buttons on Aila's Mobile Imager.
Aila_Start() and Aila_Stop() do not trigger this notification.
- Objective-C
- Swift
extern NSString *const AilaMobileImagerStateChangedNotification;
extension NSNotification.Name {
static let AilaMobileImagerStateChanged: NSNotification.Name
}
userInfo Dictionary:
| Key | Value |
|---|---|
state | @YES if scanning started, @NO if stopped |
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleImagerStateChanged:)
name:AilaMobileImagerStateChangedNotification
object:nil];
- (void)handleImagerStateChanged:(NSNotification *)notification {
BOOL isScanning = [notification.userInfo[@"state"] boolValue];
NSLog(@"Scanning state: %@", isScanning ? @"Started" : @"Stopped");
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleImagerStateChanged),
name: .AilaMobileImagerStateChanged,
object: nil
)
@objc func handleImagerStateChanged(_ notification: Notification) {
if let isScanning = notification.userInfo?["state"] as? Bool {
print("Scanning state: \(isScanning ? "Started" : "Stopped")")
}
}
AilaHardwareChangedNotification
Since 3.0.0Posted when a change in system configuration is detected (e.g., hardware connected or disconnected).
- Objective-C
- Swift
extern NSString *const AilaHardwareChangedNotification;
extension NSNotification.Name {
static let AilaHardwareChanged: NSNotification.Name
}
userInfo Dictionary:
| Key | Value |
|---|---|
hardwareClass | [NSNumber numberWithInt:Aila_GetHardwareClass()] |
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleHardwareChanged:)
name:AilaHardwareChangedNotification
object:nil];
- (void)handleHardwareChanged:(NSNotification *)notification {
AilaHardwareClass hardwareClass = [notification.userInfo[@"hardwareClass"] intValue];
NSLog(@"Hardware changed: %d", hardwareClass);
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleHardwareChanged),
name: .AilaHardwareChanged,
object: nil
)
@objc func handleHardwareChanged(_ notification: Notification) {
if let hardwareClassNum = notification.userInfo?["hardwareClass"] as? Int {
let hardwareClass = AilaHardwareClass(rawValue: hardwareClassNum)
print("Hardware changed: \(String(describing: hardwareClass))")
}
}
AilaID1CardDetectedNotification
Since 3.0.0Posted when a card is detected in the tray (when id1CardDetectionMode is enabled).
- Objective-C
- Swift
extern NSString *const AilaID1CardDetectedNotification;
extension NSNotification.Name {
static let AilaID1CardDetected: NSNotification.Name
}
userInfo Dictionary: nil
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleCardDetected:)
name:AilaID1CardDetectedNotification
object:nil];
- (void)handleCardDetected:(NSNotification *)notification {
NSLog(@"Card detected in tray");
// Trigger image capture
Aila_ID1CaptureImage(^(UIImage *image, NSError *error) {
// Handle captured image
});
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleCardDetected),
name: .AilaID1CardDetected,
object: nil
)
@objc func handleCardDetected(_ notification: Notification) {
print("Card detected in tray")
// Trigger image capture
Aila_ID1CaptureImage { image, error in
// Handle captured image
}
}
AilaMRZDetectedNotification
Since 3.0.0Posted when MRZ components are detected in the camera feed (when mrzDetectionMode is enabled).
This provides early indication that an MRZ document is present, before complete scanning occurs. The notification fires when the SDK detects any MRZ components such as document numbers, birth dates, expiry dates, or personal identification numbers.
- Objective-C
- Swift
extern NSString *const AilaMRZDetectedNotification;
extension NSNotification.Name {
static let AilaMRZDetected: NSNotification.Name
}
userInfo Dictionary: nil
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleMRZDetected:)
name:AilaMRZDetectedNotification
object:nil];
- (void)handleMRZDetected:(NSNotification *)notification {
NSLog(@"MRZ document detected");
// Update UI to guide user
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleMRZDetected),
name: .AilaMRZDetected,
object: nil
)
@objc func handleMRZDetected(_ notification: Notification) {
print("MRZ document detected")
// Update UI to guide user
}
AilaFirmwareNotification
Since 3.0.0Posted when an attempt at a firmware update is started or finished.
- Objective-C
- Swift
extern NSString *const AilaFirmwareNotification;
extension NSNotification.Name {
static let AilaFirmware: NSNotification.Name
}
userInfo Dictionary:
Each notification carries one of these keys, set to @YES:
| Key | Value |
|---|---|
primaryFirmwareStart | @YES when a primary firmware update starts |
primaryFirmwareEnd | @YES when a primary firmware update finishes successfully |
secondaryFirmwareStart | @YES when a secondary firmware update starts |
secondaryFirmwareEnd | @YES when a secondary firmware update finishes successfully |
The end keys are posted only when an update succeeds. If an update fails, no end notification is posted.
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleFirmwareUpdate:)
name:AilaFirmwareNotification
object:nil];
- (void)handleFirmwareUpdate:(NSNotification *)notification {
NSDictionary *info = notification.userInfo;
if (info[@"primaryFirmwareStart"] || info[@"secondaryFirmwareStart"]) {
NSLog(@"Firmware update started");
} else if (info[@"primaryFirmwareEnd"] || info[@"secondaryFirmwareEnd"]) {
NSLog(@"Firmware update finished");
}
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleFirmwareUpdate),
name: .AilaFirmware,
object: nil
)
@objc func handleFirmwareUpdate(_ notification: Notification) {
guard let info = notification.userInfo else { return }
if info["primaryFirmwareStart"] != nil || info["secondaryFirmwareStart"] != nil {
print("Firmware update started")
} else if info["primaryFirmwareEnd"] != nil || info["secondaryFirmwareEnd"] != nil {
print("Firmware update finished")
}
}
AilaSetCodesNotification
Since 3.0.0Posted when there is an internal setting or checking of enabled barcodes.
- Objective-C
- Swift
extern NSString *const AilaSetCodesNotification;
extension NSNotification.Name {
static let AilaSetCodes: NSNotification.Name
}
userInfo Dictionary: nil
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleSetCodes:)
name:AilaSetCodesNotification
object:nil];
- (void)handleSetCodes:(NSNotification *)notification {
NSLog(@"Barcode configuration changed");
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleSetCodes),
name: .AilaSetCodes,
object: nil
)
@objc func handleSetCodes(_ notification: Notification) {
print("Barcode configuration changed")
}
AilaSetLicenseNotification
Since 3.0.0Posted when there are internal or cloud-based changes to the SDK licensing.
- Objective-C
- Swift
extern NSString *const AilaSetLicenseNotification;
extension NSNotification.Name {
static let AilaSetLicense: NSNotification.Name
}
userInfo Dictionary:
| Key | Value |
|---|---|
accepted | NSNumber wrapping a BOOL. @YES when the license was accepted and its features applied, @NO when it was rejected. Since 3.2.0 |
reason | NSString. Present when accepted is @NO. One of bundleIdMismatch, decryptOrParseFailed or invalidStructure. Since 3.2.0 |
error | NSString. Present when reason is decryptOrParseFailed. The underlying decryption or parsing error. Since 3.2.0 |
expectedBundleIds | NSArray of NSString. Present when reason is bundleIdMismatch. The bundle ID patterns the license was issued for. An entry may end in a * wildcard, such as com.ailatech.*. Since 3.2.0 |
appBundleId | NSString. Present when reason is bundleIdMismatch. The running app's bundle ID. Since 3.2.0 |
Usage:
- Objective-C
- Swift
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleLicenseChanged:)
name:AilaSetLicenseNotification
object:nil];
- (void)handleLicenseChanged:(NSNotification *)notification {
BOOL accepted = [notification.userInfo[@"accepted"] boolValue];
if (accepted) {
NSLog(@"License applied");
// Optionally refresh license info
NSString *info = Aila_GetSDKLicensingInfo();
} else {
NSLog(@"License rejected: %@", notification.userInfo[@"reason"]);
}
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handleLicenseChanged),
name: .AilaSetLicense,
object: nil
)
@objc func handleLicenseChanged(_ notification: Notification) {
let accepted = notification.userInfo?["accepted"] as? Bool ?? false
if accepted {
print("License applied")
// Optionally refresh license info
let info = Aila_GetSDKLicensingInfo()
} else {
print("License rejected: \(notification.userInfo?["reason"] ?? "unknown")")
}
}
See Also
- AilaConfiguration - Configure notification triggers
- Aila_GetHardwareClass - Get current hardware class
- Aila_ID1CaptureImage - Capture card images