Lock Objective-C API


This document covers an outdated version of Lock for iOS. We recommend you to upgrade to v2



+ (instancetype)newLock;

Creates a new A0Lock instance using account information from Info.plist file.

A0Lock *lock = [A0Lock newLock];


+ (instancetype)newLockWithClientId:(NSString *)clientId domain:(NSString *)domain;

Creates a new A0Lock instance with Auth0 clientId and domain.

A0Lock *lock = [A0Lock newLockWithClientId:@"YOUR_CLIENT_ID" domain:@"YOUR_DOMAIN"];


+ (instancetype)newLockWithClientId:(NSString *)clientId domain:(NSString *)domain configurationDomain:(NSString *)configurationDomain;

Creates a new A0Lock instance with Auth0 clientId, domain and configurationDomain.

A0Lock *lock = [A0Lock newLockWithClientId:@"YOUR_CLIENT_ID" domain:@"YOUR_DOMAIN" configurationDomain:@"YOUR_CONFIG_DOMAIN"];


- (A0APIClient *)apiClient;

Returns an instance of the API application for Authentication API configured for your application.

A0APIClient *client = [lock apiClient];


- (A0UserAPIClient *)newUserAPIClientWithIdToken:(NSString *)idToken;

Returns a new instance of the API client for Auth0 API with the credentials of a authenticated user obtained from the ID Token

A0UserAPIClient *client = [lock newUserAPIClientWithIdToken:@"AN ID TOKEN"];


- (BOOL)handleURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication;

Handle URL received from AppDelegate when application is called from a third party at the end of an authentication flow.

[lock handleURL:URL sourceApplication:sourceApplication];


- (void)registerAuthenticators:(NSArray *)authenticators;

Register IdP authenticators that will be used for Social & Enterprise connections. By default all Social & Enterprise authentications are performed by using the web flow with Safari but you can plug your own authenticator for a connection (for example, you can register A0FacebookAuthenticator in order to login with FB native SDK).

[lock registerAuthenticators:@[facebook, twitter]];


- (void)applicationLaunchedWithOptions:(NSDictionary *)launchOptions;

Handle application launched event.

[lock applicationLaunchedWithOptions:launchOptions];


- (void)clearSessions;

Remove all stored sessions of any IdP in your application. If the user logged in using Safari, those sessions will not be cleaned.

[lock clearSessions];



- (instancetype)initWithLock:(A0Lock *)lock;

Initialise 'A0LockViewController' using a A0Lock instance.

A0LockViewController *controller = [[A0LockViewController alloc] initWithLock:lock];


@property (copy, nonatomic) void(^onAuthenticationBlock)(A0UserProfile *profile, A0Token *token);

Block that is called on successful authentication. It has two parameters profile and token, which will be non-nil unless login is disabled after signup.

controller.onAuthenticationBlock = ^(A0UserProfile *profile, A0Token *token) {
  NSLog(@"Auth successful: profile %@, token %@", profile, token);


@property (copy, nonatomic) void(^onUserDismissBlock)();

Block that is called on when the user dismisses the Login screen. Only when closable property is YES.

controller.onUserDismissBlock = ^() {
  NSLog(@"User dismissed login screen.");


@property (assign, nonatomic) BOOL usesEmail;

Enable the username to be treated as an email (and validated as one too) in all Auth0 screens. Default is YES

controller.usesEmail = NO;


@property (assign, nonatomic) BOOL closable;

Allows the A0LockViewController to be dismissed by adding a button. Default is NO

controller.closable = YES;


@property (assign, nonatomic) BOOL loginAfterSignUp;

After a successful Signup, A0LockViewController will attempt to login the user if this property is YES otherwise will call onAuthenticationBlock with both parameters nil. Default value is YES

controller.loginAfterSignup = NO;


@property (assign, nonatomic) A0AuthParameters *authenticationParameters;

List of optional parameters that will be used for every authentication request with Auth0 API. By default it only has 'openid' and 'offline_access' scope values. For more information check out our Wiki

controller.authenticationParameters.scopes = @[A0ScopeOfflineAccess, A0ScopeProfile];


@property (strong, nonatomic) UIView *signUpDisclaimerView;

View that will appear in the bottom of Signup screen. It should be used to show Terms & Conditions of your app.

UIView *view = //..
controller.signupDisclaimerView = view;


@property (assign, nonatomic) BOOL useWebView;

When the authentication requires to open a web login, for example Linkedin, it will use an embedded UIWebView instead of Safari if it's YES. We recommend using Safari for Authentication since it will always save the User session. This means that if the user is already signed in, for example in Linkedin, and they click on the Linkedin button, it will just work. Default values is NO

controller.useWebView = YES