SMS

A0SMSLockViewController authenticates without using a password with SMS. In order to be able to authenticate the user, your application must have the SMS connection enabled and configured in your dashboard.

Heads up! This page is documentation for an outdated version of Lock for iOS (version 1). Check out the Lock v1 to Lock v2 migration guide, for information on migrating to v2, or the Lock v2 Documentation.

First instantiate A0SMSLockViewController and register the authentication callback that will receive the authenticated user's credentials.

The next step is register a block to return an API Token used to register the phone number and send the login code with SMS. This token can be generated in Auth0 API v2 page, just select the scope create:users and copy the generated API Token.

Finally present it to the user:

A0Lock *lock = ... //Fetch Lock from where its stored
A0SMSLockViewController *controller = [lock newSMSViewController];
controller.auth0APIToken = ^{
    return @"Copy API v2 token here";
};
controller.onAuthenticationBlock = ^(A0UserProfile *profile, A0Token *token) {
    // Do something with token & profile. e.g.: save them.
    // Lock will not save the Token and the profile for you.
    // And dismiss the UIViewController.
    [self dismissViewControllerAnimated:YES completion:nil];
};
[lock presentSMSController:controller fromController:self];
let lock = ... // Fetch Lock from where its stored
let controller: A0SMSLockViewController = lock.newSMSViewController()
controller.onAuthenticationBlock = { (profile, token) in
   // Do something with token & profile. e.g.: save them.
   // Lock will not save the Token and the profile for you.
   // And dismiss the UIViewController.
   self.dismiss(animated: true, completion: nil)
}
lock.presentSMSController(controller, from: self)

And you'll see SMS login screen

Lock SMS Screenshot