+ Start a Discussion
Ganesh GuturiGanesh Guturi 

How to show back button or set frame to Salesforce login screen in iOS Native app?

I'm showing Salesforce login screen in my iOS native application after loading my root view, but their login screen (WebView) is covering my entire screen and I'm not able to show the status bar and navigation bar at top side. I have written code in willDisplayAuthWebView method as mentioned below
- (void)authManager:(SFAuthenticationManager *)manager willDisplayAuthWebView:(UIWebView *)view{ 
CGRect newFrame = self.view.frame; 
newFrame.origin.y += 64;
view.frame = newFrame;
[Self.View addSubview:view]; 
}
and the screen shot is here
User-added image

but no luck. Is there anyway to handle this issue. Please help me. Thanks in advance.

 
Best Answer chosen by Ganesh Guturi
Ganesh GuturiGanesh Guturi
Hi,

Somehow I have achived it by adding the following code
UIView *authSFLoginCustomViewController = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; authSFLoginCustomViewController.backgroundColor =  [UIColor colorWithRed:(53 / 255.0f)  green:(146 / 255.0f) blue:(220 / 255.0f) alpha:1.0f];
        
SFAuthenticationViewHandler *authHandler = [[SFAuthenticationViewHandler alloc] initWithDisplayBlock:^(SFAuthenticationManager *authManager, UIWebView *authWebView) {

authWebView.frame = CGRectMake(0, 44, authWebView.frame.size.width, authWebView.frame.size.height-64);
                                                       
UIActivityIndicatorView *SFActivityIndicatorView = [[UIActivityIndicatorView alloc]init];
[SFActivityIndicatorView setCenter:authWebView.center];
SFActivityIndicatorView.color = [UIColor darkGrayColor];
[SFActivityIndicatorView startAnimating];
SFActivityIndicatorView.alpha = 0.0;
[authWebView addSubview:SFActivityIndicatorView];
[authSFLoginCustomViewController addSubview:authWebView];
[self.view addSubview:authSFLoginCustomViewController];
}dismissBlock:^(SFAuthenticationManager *authViewManager) { 
 }];                                              
 [SFAuthenticationManager sharedManager].authViewHandler = authHandler;


In my case its needed as I have a home screen about my company as a first screen and from there I have to show Salesforce login as second view. If user wants to come back to my first screen then he/she can come easily now.

All Answers

KevinPKevinP
I don't know of any way to do this but more importantly, why would you want to ? a back button from the login screen to where?
Ganesh GuturiGanesh Guturi
Thank you for reply. I have a Home(first) screen which is showing some information, from there Salesforce login screen is starting. Now the problem is, after showing Salesforce login screen if I want to back(first) to Home screen how I can come back? right now on;y option is kill tha application. Thank you.
Gaurav ThakurGaurav Thakur
Dont know if you found any resolution but it is possible in sdk 2.1, to customize the Login Screen check the discussion here https://plus.google.com/111635622185867950837/posts/TbWro7cQBmb

However I am not able to do on the fly changing of the endpoint for the application in iOS..
 
Ganesh GuturiGanesh Guturi
Hi,

Somehow I have achived it by adding the following code
UIView *authSFLoginCustomViewController = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; authSFLoginCustomViewController.backgroundColor =  [UIColor colorWithRed:(53 / 255.0f)  green:(146 / 255.0f) blue:(220 / 255.0f) alpha:1.0f];
        
SFAuthenticationViewHandler *authHandler = [[SFAuthenticationViewHandler alloc] initWithDisplayBlock:^(SFAuthenticationManager *authManager, UIWebView *authWebView) {

authWebView.frame = CGRectMake(0, 44, authWebView.frame.size.width, authWebView.frame.size.height-64);
                                                       
UIActivityIndicatorView *SFActivityIndicatorView = [[UIActivityIndicatorView alloc]init];
[SFActivityIndicatorView setCenter:authWebView.center];
SFActivityIndicatorView.color = [UIColor darkGrayColor];
[SFActivityIndicatorView startAnimating];
SFActivityIndicatorView.alpha = 0.0;
[authWebView addSubview:SFActivityIndicatorView];
[authSFLoginCustomViewController addSubview:authWebView];
[self.view addSubview:authSFLoginCustomViewController];
}dismissBlock:^(SFAuthenticationManager *authViewManager) { 
 }];                                              
 [SFAuthenticationManager sharedManager].authViewHandler = authHandler;


In my case its needed as I have a home screen about my company as a first screen and from there I have to show Salesforce login as second view. If user wants to come back to my first screen then he/she can come easily now.
This was selected as the best answer