This example shows how to setup a single sign-on to login into Strategy using the Blackberry authorized user. This can be done by using Trusted authentication to authenticate against Strategy using the Blackberry authenticated user as the trusted user.
Using a custom App Delegate, it is possible to get the Blackberry User ID and set the corresponding header value that the Mobile Server expects. In "didFinishLaunchingWithOptions" you can use the following observer to get the GD user ID:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// CustomLoginView *loginView = [[CustomLoginView alloc] initWithFrame:self.window.frame];
// MSIAuthenticationPromptViewController *loginViewController = [[MSIAuthenticationPromptViewController alloc] init];
// MSIAuthenticationModule *loginModule = [[MSIAuthenticationModule alloc] init];
// [[MSIMobileLoginManager sharedMobileLoginManager] setView:loginView controller:loginViewController module:loginModule forPromptType:AuthenticationPromptType];
NSLog(@"CUSTOM APP DELEGATE DID FINISH LAUNCHING");
relaunched = true;
// this notification is triggered when GD authorization has finished.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getGDID) name:MSI_APPLICATION_DID_FINISH_LAUNCHING_NOTIFICATION object:nil];
BOOL res = [super application:application didFinishLaunchingWithOptions:launchOptions];
return res;
}
-(void) getGDID {
if(!relaunched){
NSLog(@"not relaunched");
return;
}
NSLog(@"relaunched");
NSLog(@"Finished Initialization");
NSDictionary *gdApplicationConfig = [[GDiOS sharedInstance] getApplicationConfig];
//NSLog(@"gdApplicationConfig is: %@", gdApplicationConfig);
NSString *userID = gdApplicationConfig[@"userId"];
NSLog(@"userID is: %@", userID);
// setting header values -
SDKEnvSettings *sdkEnvSettings = [MSIGeneric getSDKEnvSettings];
[sdkEnvSettings setValue:userID forHTTPHeaderField:@"SM_USER"];
// prevent it from being called again in this run cycle
relaunched = false;
}