iOS Objective-C Introduction

This is the very beginning of a simple, practical, multi-step quickstart that will guide you through managing authentication in your iOS apps with Auth0.

Seed Project

Here is a seed project containing an empty project with only the required dependencies installed.

Sample Project

Download this sample project configured with your Auth0 API Keys.

System Requirements
  • CocoaPods 1.1.1
  • Version 8.2 (8C38)
  • iPhone 6 - iOS 10.2 (14C89)
Show requirements

This seed project can be useful as a starting point for the app to which you need to integrate authentication.

Sample Projects

Each tutorial in the series includes a link to its corresponding sample project, which demonstrates how to achieve the goal from the tutorial in question. You can check out all the samples here.

Dependencies

Each tutorial will require you to use either Lock or the Auth0.swift toolkit, or both.

A brief overview:

  • Lock is a widget that is easy to present in your app. It contains default templates (that can be a bit customized) for login with email/password, sign up, social providers integration, and also password recovery.
  • Auth0.swift is a toolkit that lets you communicate neatly with many of the basic Auth0 API functions.

These dependencies are already integrated in each sample project through Cocoapods. We have chosen to use an approach of not git-ignoring them in the samples repo; that way, you don't have to worry about running pod commands. Once you've cloned the repo, the samples are ready to be run!

It's recommended that, as a starting point for your project, you download the seed project described above, which already includes these dependencies.

Otherwise, if you're starting an empty project of your own, or if you want to add authentication to an existing project from yours, you have to make sure you install them:

Cocoapods

If you are using Cocoapods, add these lines to your Podfile:

use_frameworks!
pod 'Lock', '~> 1.28'
pod 'Auth0', '~> 1.4'

Then, run pod install.

For further reference on Cocoapods, check their official documentation.

Your First Steps

Make sure you complete these steps before going through any tutorial:

1. Create a Client

If you haven't already done so, create a new client application in your Auth0 dashboard and choose Native.

App Dashboard

2. Add your credentials

Add your credentials in Auth0.plist. You have to create that file if it doesn't already exist in your project:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>ClientId</key>
  <string>YOUR_CLIENT_ID</string>
  <key>Domain</key>
  <string>YOUR_AUTH0_DOMAIN</string>
</dict>
</plist>

3. Configure your callback URLs

Go to your Client Dashboard and make sure that Allowed Callback URLs contains the following:

{YOUR_APP_BUNDLE_IDENTIFIER}:///ios/{YOUR_APP_BUNDLE_IDENTIFIER}/callback

In your application's Info.plist file, register your iOS Bundle Identifier as a custom scheme. To do so, open the Info.plist as source code, and add this chunk of code under the main <dict> entry:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>None</string>
        <key>CFBundleURLName</key>
        <string>auth0</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>{YOUR_APP_BUNDLE_IDENTIFIER}</string>
        </array>
    </dict>
</array>

You're all set up to start integrating Auth0 in your app!

The tutorial guides contained in this section will teach you the different things you can do with it. It's recommendable that you follow them sequentially in order, as they are progressive and there is content that usually needs to be learned from previous tutorials.

Have fun!

Next Tutorial
2. Login
Use Auth0 for FREECreate free Account