Created
February 23, 2016 18:14
-
-
Save kevb10/f2c6fc18372bcdc8719d to your computer and use it in GitHub Desktop.
Login user then connect to chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) loginForMessaging:(NSString *)username andPassword:(NSString *)password withCompletion:(void (^)(BOOL finished))completion { | |
__weak __typeof(self)weakSelf = self; | |
[QBRequest logInWithUserLogin:username password:password successBlock:^(QBResponse *response, QBUUser *user) { | |
if (user) { | |
__typeof(self) strongSelf = weakSelf; | |
[[QBChat instance] connectWithUser:user completion:^(NSError * _Nullable error) { | |
if (!error) { | |
[strongSelf registerForRemoteNotifications]; | |
completion(true); | |
} else { | |
[SVProgressHUD showInfoWithStatus:@"error connecting to chat"]; | |
} | |
}]; | |
} | |
} errorBlock:^(QBResponse *response) { | |
// error handling | |
NSLog(@"error: %@", response.error); | |
completion(false); | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment