Skip to content

Instantly share code, notes, and snippets.

@kevb10
Created February 23, 2016 18:14
Show Gist options
  • Save kevb10/f2c6fc18372bcdc8719d to your computer and use it in GitHub Desktop.
Save kevb10/f2c6fc18372bcdc8719d to your computer and use it in GitHub Desktop.
Login user then connect to chat
- (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