Skip to content

Instantly share code, notes, and snippets.

@llSourcell
Last active November 4, 2015 18:13
Show Gist options
  • Save llSourcell/4816a85a1bd2db280d43 to your computer and use it in GitHub Desktop.
Save llSourcell/4816a85a1bd2db280d43 to your computer and use it in GitHub Desktop.
- (void)myMethod {
PFUser *user = [PFUser user];
user.username = @"my name";
user.password = @"my pass";
user.email = @"[email protected]";
// other fields can be set just like with PFObject
user[@"phone"] = @"415-392-0202";
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
// Now that they've authenticated with Parse, we can 'login' via IPM
[[IPMessagingManager sharedManager] loginWithIdentity:user.username];
} else { NSString *errorString = [error userInfo][@"error"]; // Show the errorString somewhere and let the user try again.
}
}];
}
- (BOOL)loginWithIdentity:(NSString *)identity {
if (self.client) {
[self logout];
}
[self storeIdentity:identity];
NSString *token = [self tokenForIdentity:identity];
self.client = [TwilioIPMessagingClient ipMessagingClientWithToken:token
delegate:nil];
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment