function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mobillemobille 

iOS Native RestApi

Hi All,

 

 

Ima integrating salesforce in ipad app. I want to set Session time out for my salesforce native app through restapi.Is It Possible.???or if i change timeout in my from my salesforce account ,is it applicable for my native app?

 

Please help me?

Tom GersicTom Gersic

Session timeout is controlled in Salesforce. Yes, it is applicable to your native app. Though if you're using the refresh token flow, it'll get you a new access token every time it expires. What are you trying to accomplish?

Kevin HawkinsKevin Hawkins

As Tom said, while your app will adhere to the session timeouts that are set for the org, the OAuth authentication functionality of Mobile SDK apps will automatically refresh your session if/when it times out.

 

Other than that, I do not believe there's any way to remotely change the session timeout values for your org.  That's an administrative function that you must perform on the site.

 

Cheers,

Kevin

 

mobillemobille

Hi kevin thanks for your answer.

I have  small issue.

when iam logging into my native app it asking for permissions to access user data.if accept iam redirecting to my app home page.upto this it is fine.

 

 

Issue is when iam deny permissions app crashes..?????

can you help me...when iam deny the permissons i want to show login screen again..how to accomplish this.

Gaurav KheterpalGaurav Kheterpal

You should not remove coordinator view in oauthCoordinator delegate ""didFailWithError"" in the class

 

 

""SFNativeRestAppDelegate""

- (void)oauthCoordinator:(SFOAuthCoordinator *)coordinator didFailWithError:(NSError *)error {
    NSLog(@""oauthCoordinator:didFailWithError: %@"", error);
    //[coordinator.view removeFromSuperview];
    
    if (error.code == kSFOAuthErrorInvalidGrant) {  //invalid cached refresh token
        //restart the login process asynchronously
        NSLog(@""Logging out because oauth failed with error code: %d"",error.code);
        [self performSelector:@selector(logout) withObject:nil afterDelay:0];
    }
    else if(error.code == kSFOAuthErrorAccessDenied)
    {
        NSLog(@""Logging out because AccessDenied error code: %d"",error.code);
        [self performSelector:@selector(logout) withObject:nil afterDelay:0];
        
    }
    else {
        // show alert and retry
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""Salesforce Error""
                                                        message:[NSString stringWithFormat:@""Can't connect to salesforce: %@"", error]
                                                       delegate:self
                                              cancelButtonTitle:@""Retry""
                                              otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
}"

 

I hope this helps.

 

Regards,

Gaurav

 

Kevin HawkinsKevin Hawkins

The OAuth view is removed when there's an error, because it can no longer be used, regardless of the next stage of the work flow.  It will be recreated when authentication happens again, either through the user retrying, or through an automatic logout/re-login in the case of invalid refresh credentials.

 

I'll take a look at the denied authorization use case, and see if I can recreate a crashing scenario there.

 

Cheers,

Kevin