Updates to the HID Approve SDK for Apple iOS
This page details the design changes made in the new HID® Approve™ SDK for Apple® iOS® .
Please refer to the code examples provided below that illustrate the code changes, as well as Add the SDK to Your App.
What's New in Version 5.1 from 4.0
SDK Updates
HIDTransactionInfo
NEW method “getTransaction”
-(id<HIDTransaction>)getTransaction:(NSString*)sessionPassword withParams:(NSArray*)parameters error:(NSError**)error;
HIDTransaction
UPDATE protocol moved from “HIDDevice.h” header
HIDProgressListener
UPDATE protocol moved from “HIDDevice.h” header
UPDATE method “onEventReceived”
- (HIDEventResult*)onEventReceived:(id<HIDEvent>)event;
HIDProgressEvent
UPDATE protocol moved from “HIDDevice.h” header
NEW enumeration “HIDEventResultCode”
NEW interface “HIDPasswordPromptResult”
NEW protocol “HIDEvent”
HIDContainerInitialization
UPDATE interface moved from “HIDDevice.h” header
DEPRECATED field “initialPassword” (use ProgressListener)
HIDDevice
DEPRECATED method “retrieveTransaction” (use TransactionInfo.getTransaction)
-(id<HIDTransaction>)retrieveTransaction:(NSString*)transactionId withPassword:(NSString*)sessionPassword withParams:(NSArray*)parameters error:(NSError**)error;
DEPRECATED method “createContainer” (use new method)
-(id<HIDContainer>)createContainer:(HIDContainerInitialization*)config withListener:(NSObject<HIDProgressListener>*)listener error:(NSError**)error;
DEPRECATED method “reset” (use new method HIDDeviceFactory.reset)
- (BOOL)reset:(NSArray*)parameters error:(NSError**)error;
DEPRECATED method “getDefaultInitializationPolicy” (use ProgressListener)
- (id<HIDProtectionPolicy>)getDefaultInitializationPolicy:(NSError**)error;
NEW method “createContainer”
-(id<HIDContainer>)createContainer:(HIDContainerInitialization*)config withSessionPassword:(NSString*)sessionPassword withListener:(NSObject<HIDProgressListener>*)listener error:(NSError**)error;
HIDDeviceFactory
DEPRECATED method “newInstance” (use new method)
-(id<HIDDevice>)newInstance:(HIDConnectionConfiguration*)config error:(NSError**)error;
NEW method “newInstance”
-(id<HIDDevice>)newInstance:(HIDConnectionConfiguration*)config withSessionPassword:(NSString*)sessionPassword error:(NSError**)error;
NEW method “reset”
+(void)reset:error:(NSError**)error;
SDK Additions and New Features
NEW interface “HIDContainerRenewal”
HIDContainer
NEW method “getCreationDate”
-(NSDate*)getCreationDate:(NSError**)error;
NEW method “getExpiryDate”
-(NSDate*)getExpiryDate:(NSError**)error;
NEW method “getRenewalDate”
-(NSDate*)getRenewalDate:(NSError**)error;
NEW method “isRenewable”
-(Boolean)isRenewable:(NSString*)sessionPassword error:(NSError**)error;
NEW method “renew”
-(Boolean)renew:(HIDContainerRenewal*)config withSessionPassword:(NSString*) sessionPassword withListener:(NSObject<HIDProgressListener>*)listener error:(NSError**)error;
HIDErrorCode
NEW enumeration value “HIDPasswordCancelled”
NEW enumeration value “HIDServerUnsupportedOperation”
NEW enumeration value “HIDServerOperationFailed”
What's New in Version 4.0 from 3.0
SDK Addition
HIDContainer
NEW method “IsFIPSModeEnabled” – Reserved for Future Use.
Code Examples
Transaction Retrieval
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig error:&error];
// get transaction
id<HIDTransactionInfo> pTransactionInfo = [pDevice retrieveTransactionInfo:transactionId error:&error];
id<HIDTransaction> pTransaction = [pDevice retrieveTransaction:myTransactionId withPassword:mySessionPwd withParams:nil error:&error];
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig withSessionPassword:mySessionPwd error:&error];
// get transaction
id<HIDTransactionInfo> pTransactionInfo = [pDevice retrieveTransactionInfo:myTransactionId error:&error];
id<HIDTransaction> pTransaction = [pTransactionInfo getTransaction:mySessionPwd withParams:nil error:&error];
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig error:&error];
// get transaction
id<HIDTransactionInfo> pTransactionInfo = [pDevice retrieveTransactionInfo:myTransactionId error:&error];
id<HIDTransaction> pTransaction = [pTransactionInfo getTransaction:mySessionPwd withParams:nil error:&error];
Provisioning / Container Creation
// progress listener
-(void)onEventReceived:(id<HIDProgressEvent>)event {
NSArray* params = [event parameters];
NSString* message; NSString* percent;
for (HIDParameter* p in params) {
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_MESSAGE]==NSOrderedSame)
message = [p value];
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_PERCENT]==NSOrderedSame)
percent = [p value];
}
NSString* text = [NSString stringWithFormat:@"%@ (%@)", message, percent];
NSLog(@"Event Received: %@", text);
}
// provisioning
-(void)doProvisioning {
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig error:&error];
// new container
HIDContainerInitialization* config = [[HIDContainerInitialization alloc] init];
config.activationCode = [[NSString alloc] initWithData:myActivationCodeData encoding:NSUTF8StringEncoding];
config.initialPassword = myInitialPassword;
config.pushId = myPushID;
config.containerFriendlyName = myServiceName;
id<HIDContainer> pContainer = [pDevice createContainer:config withListener:self error:&error];
}
// progress listener
-( HIDEventResult*)onEventReceived:(NSObject<HIDEvent>*)event {
if ([event isKindOfClass:[HIDPasswordPromptEvent class]]) {
// password request
HIDPasswordPromptEvent* pPwdEvent = (HIDPasswordPromptEvent*)event;
return [[HIDPasswordPromptResult alloc] initWithCode:Continue andPassword:myInitialPassword];
}
else { // progress message
NSArray* params = [event parameters];
NSString* message; NSString* percent;
for (HIDParameter* p in params) {
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_MESSAGE]==NSOrderedSame)
message = [p value];
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_PERCENT]==NSOrderedSame)
percent = [p value];
}
NSString* text = [NSString stringWithFormat:@"%@ (%@)", message, percent];
NSLog(@"Event Received: %@", text);
}
return [[HIDEventResult alloc] initWithCode:(Continue)];
}
// provisioning
-(void)doProvisioning {
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig withSessionPassword:mySessionPwd error:&error];
// new container
HIDContainerInitialization* config = [[HIDContainerInitialization alloc] init];
config.activationCode = [[NSString alloc] initWithData:myActivationCodeData encoding:NSUTF8StringEncoding];
// NOTE: “config.initialPassword” is not supported; use listener
config.pushId = myPushID;
config.containerFriendlyName = myServiceName;
id<HIDContainer> pContainer = [pDevice createContainer:config withSessionPassword:mySessionPwd withListener:self error:&error];
}
// progress listener
-( HIDEventResult*)onEventReceived:(NSObject<HIDEvent>*)event {
if ([event isKindOfClass:[HIDPasswordPromptEvent class]]) {
// password request
HIDPasswordPromptEvent* pPwdEvent = (HIDPasswordPromptEvent*)event;
return [[HIDPasswordPromptResult alloc] initWithCode:Continue andPassword:myInitialPassword];
}
else { // progress message
NSArray* params = [event parameters];
NSString* message; NSString* percent;
for (HIDParameter* p in params) {
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_MESSAGE]==NSOrderedSame)
message = [p value];
if ( [[p key] caseInsensitiveCompare:HID_PARAM_PROGRESSEVENT_PERCENT]==NSOrderedSame)
percent = [p value];
}
NSString* text = [NSString stringWithFormat:@"%@ (%@)", message, percent];
NSLog(@"Event Received: %@", text);
}
return [[HIDEventResult alloc] initWithCode:(Continue)];
}
// provisioning
-(void)doProvisioning {
NSError* error;
// get device
HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig error:&error];
// new container
HIDContainerInitialization* config = [[HIDContainerInitialization alloc] init];
config.activationCode = [[NSString alloc] initWithData:myActivationCodeData encoding:NSUTF8StringEncoding];
// NOTE: “config.initialPassword” is not supported; use listener
config.pushId = myPushID;
config.containerFriendlyName = myServiceName;
id<HIDContainer> pContainer = [pDevice createContainer:config withSessionPassword:mySessionPwd withListener:self error:&error];
}