Create a central class for logon-related work, so your code remains clean.
This example is a simple interface of the logon handler:
#import <Foundation/Foundation.h> #import "MAFLogonNGPublicAPI.h" #import "MAFLogonManagerNG.h" #import "MAFLogonUIViewManager.h" #import "MAFLogonNGDelegate.h" @interface MyLogonHandler : NSObject <MAFLogonNGDelegate> @property (strong, nonatomic) MAFLogonUIViewManager *logonUIViewManager; @property (strong, nonatomic) NSObject<MAFLogonNGPublicAPI> *logonManager; @end
This class implements MAFLogonNGDelegate and exposes an instance of MAFLogonUIViewManager.
#import "MyLogonHandler.h"
@implementation MyLogonHandler
-(id) init{
self = [super init];
if(self){
self.logonUIViewManager = [[[MAFLogonUIViewManager alloc] init] autorelease];
// save reference to LogonManager for code readability
self.logonManager = self.logonUIViewManager.logonManager;
#warning You must set your own application id. The application id can be specified in the info.plist file.
// set up the logon delegate
[self.logonManager setLogonDelegate:self];
}
return self;
}
@end
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>keyMAFLogonApplicationId</key> <string>com.example.ios.app</string> </dict> </plist>
#pragma mark - MAFLogonNGDelegate impolementation
-(void) logonFinishedWithError:(NSError*)anError {
NSLog(@"logonFinishedWithError:%@", anError);
}
-(void) lockSecureStoreFinishedWithError:(NSError*)anError {
NSLog(@"lockSecureStoreFinishedWithError:%@", anError);
}
-(void) updateApplicationSettingsFinishedWithError:(NSError*)anError { NSLog(@"updateApplicationSettingsFinishedWithError:%@", anError);
}
-(void) uploadTraceFinishedWithError:(NSError *)anError {
NSLog(@"uploadTraceFinishedWithError:%@", anError);
}
-(void) changeBackendPasswordFinishedWithError:(NSError*)anError {
NSLog(@"Password change with error:%@", anError);
}
-(void) deleteUserFinishedWithError:(NSError*)anError {
NSLog(@"deleteUserFinishedWithError:%@", anError);
}
-(void) changeSecureStorePasswordFinishedWithError:(NSError*)anError {
NSLog(@"changeSecureStorePasswordFinishedWithError:%@", anError);
}
-(void) registrationInfoFinishedWithError:(NSError*)anError {
NSLog(@"registrationInfoFinishedWithError:%@", anError);
}
-(void) startDemoMode {
NSLog(@"startDemoMode");
}