UserService Authenticate - How to check request time out

+1 vote

I faced this problem today while authenticating username and password using following method using iOS sdk.

How can i check the request time out problem using following code. 

NSString *userName = @"Nick";
NSString *pwd = @"********";
User *user = [userService authenticate:userName password:pwd]; 
NSLog(@"userName is %@" , user.userName);
NSLog(@"sessionId is %@" ,  user.sessionId);
 
asked Mar 14, 2014 in App42 Cloud API-BaaS by nilesh (109 points)

2 Answers

+1 vote
 
Best answer
Hi,
We have added the request time-out detection in our latest SDK. 
You can download the latest SDK from our github repo.
 
App42 SDK throws exceptions in case of wrong parameter like null, empty or no internet connection or request time-out etc.
 
You should always call APIs inside try-catch block as follows:
 @try
    {
        NSString *userName = @"User Name";
        NSString *password = @"******";
        
        User *user = [userService authenticateUser:userName password:password];
        
        NSLog(@"User Name=%@",user.userName);
        NSLog(@"Email = %@",user.email);
        NSLog(@"SessionId = %@",user.sessionId);
        
    }
    @catch (App42Exception *exception)
    {
        NSLog(@"Exception = %@",[exception reason]);
        NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
        NSLog(@"App Error Code = %d",[exception appErrorCode]);
        NSLog(@"User Info = %@",[exception userInfo]);
    }
    @finally
    {
        
    }
 
answered Mar 31, 2014 by rajeev.etc (1,660 points)
selected Apr 22, 2014 by nilesh
0 votes
Hi,

We will be adding request time-out detection by next release, scheduled on 21st March. We will notify you once it is out.
answered Mar 14, 2014 by rajeev.etc (1,660 points)
thanks rajeev :)
rajeev, just a small suggession. when we pass wrong username password to authenticate method. It still returns User object with blank data. Instead it should returns "nil" object.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...