You need to sign in to do that
Don't have an account?
Gaurav Thakur
Modifying endpoint URL using Settings, like Salesforce 1 iOS Native app Login Screen
I am creating the iOS Native app in which I am customizing the Login page to look like Salesforce1 iOS app page. It also includes a Settings button which allows user to switch to a different endpoint URL using a dropdown.
I was successful in creating a cutomized page, loading the Login screen and authenticating the user.
My problem is that when I switch the endpoint URL to say Sandbox(by default the app is pointing to Production), using the Settings dropdown using the below code.
I know for sure that the Sandbox endpoint is set, because when I kill the app and reopen it then the Login Page is loading the Sandbox login page.
I want to know how would I be able to replicate the Settings behavior to take the Sandbox endpoint at runtime, and not the Production endpoint(default one) without letting the user to kill the application.
I was successful in creating a cutomized page, loading the Login screen and authenticating the user.
My problem is that when I switch the endpoint URL to say Sandbox(by default the app is pointing to Production), using the Settings dropdown using the below code.
[[SFUserAccountManager sharedInstance] setLoginHost:loginHost];and reload the UIWebView Login page again using the below code, it does not set the endpoint that I had selected from the dropdown.
SFAuthenticationViewHandler *authHandler = [[SFAuthenticationViewHandler alloc] initWithDisplayBlock:^(SFAuthenticationManager *authManager, UIWebView *authWebView) { //authController is the custom ViewContoller which has the UIWebView and in this block I am asigning the webview recevied from the SFDC SDK. authController.authViewCompleted = NO; authController.authWebView = authWebView; authWebView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; authWebView.frame = authController.webViewHolder.bounds; [rootViewController presentViewController:authController animated:TRUE completion:nil]; } dismissBlock:^(SFAuthenticationManager *authViewManager) { authController.authViewCompleted = TRUE; [authController dismissViewControllerAnimated:TRUE completion:nil]; }]; _notificationNameDictionary = @{kSFUserLogoutNotification : kPSSUserLogoutNotification, kSFUserLoggedInNotification : kPSSUserLoggedInNotification, kSFLoginHostChangedNotification : kPSSLoginHostChangedNotification}; self.authManager.authViewHandler = authHandler; [self.authManager loginWithCompletion:completionBlock failure:failureBlock];
I know for sure that the Sandbox endpoint is set, because when I kill the app and reopen it then the Login Page is loading the Sandbox login page.
I want to know how would I be able to replicate the Settings behavior to take the Sandbox endpoint at runtime, and not the Production endpoint(default one) without letting the user to kill the application.
If my answer helps resolve your query, please select it as a 'Best Answer' so that it benefits others and helps us improve the overall quality of the forums.
I have solved it by accessing credentials property like below
if([SFAuthenticationManager sharedManager].coordinator){
[SFAuthenticationManager sharedManager].coordinator.credentials.domain = @"test.salesforce.com";
[SFAuthenticationManager sharedManager].coordinator.credentials.redirectUri = @"https://test.salesforce.com/services/oauth2/success";
}