Reputation: 3663
I have a question regarding Quick blox API. Right now I am sign up an user using below code.
[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
// session created
QBUUser *user = [QBUUser user];
user.password = userPasswordTextField.text;
user.login = userNameTextField.text;
user.fullName = userRealNameTextField.text;
user.email = userEmailTextField.text;
// Registration sign up of User
[QBRequest signUp:user successBlock:^(QBResponse *response, QBUUser *user) {
[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
NSLog(@"checkingl registering");
[QBRequest userWithLogin:user.login successBlock:^(QBResponse *response, QBUUser *user) {
NSLog(@"checkingl updatingqb");
} errorBlock:^(QBResponse *response) {
// Handle error
}];
}errorBlock:^(QBResponse *response) {
// Handle error
}];
} errorBlock:^(QBResponse *response) {
// Handle error here
NSLog(@"error while signing up with QB");
NSLog(@"fail sign Up %@",response);;
[self showAlert:nil message:@"User with login that has already been taken" cancelButtonTitle:nil otherButtonTitle:@"OK"];
return ;
}];
} errorBlock:^(QBResponse *response) {
// handle errors
NSLog(@" error in creating session %@", response.error);
}];
In above code first I am creating a session and sign up an new user, then I am login user. At sign up time I did't log in user for QuickBlox Chat at signup time, But later when I will log in into Quick blox chat in another module, still I have to create new session or I have to maintain new session.
Upvotes: 3
Views: 1329
Reputation: 789
Any session will remain valid for 2 hours after the last request to QuickBlox. To check a session's expiration date use this next snippet of code:
NSDate *sessionExpiratioDate = [QBBaseModule sharedModule].tokenExpirationDate;
NSDate *currentDate = [NSDate date];
NSTimeInterval interval = [currentDate timeIntervalSinceDate:tokenExpirationDate];
if(interval > 0){
// recreate session here
}
Check this guide. This feature is available since 1.8 iOS SDK.
Reference: Igor Khomenko
Upvotes: 4