Developer

Create Your Logon Handler

Using a central class for the logon-related work is a best practice for writing code.

Context

This example is code for a simple interface of the logon handler. The class implements MAFLogonNGDelegate and exposes an instance of MAFLogonUIViewManager.

#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

Example

This is an example implementation (MyLogonHandler.m) of the logon handler:
#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
In the info.plist file of your Xcode project, add these lines:
<?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>
You must implement all MAFLogonNGDelegate methods in MyLogonHandler:
#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");
}