Stytch iOS UIKit example application
Stytch iOS UIKit example application
Overview
This example application demonstrates how one may use Stytch within a UIKit iOS application.
This project uses Stytch’s iOS SDK which provides headless methods to securely interact with Stytch.
This application features SMS OTP as well as Apple and Google OAuth authentication. You can use this application’s source code as a learning resource, or use it as a jumping off point for your own project. We are excited to see what you build with Stytch!
Set up
Follow the steps below to get this application fully functional and running using your own Stytch credentials.
In the Stytch Dashboard
-
Create a Stytch account. Once your account is set up a Project called “My first project” will be automatically created for you.
-
Within your new Project, navigate to SDK configuration, and make the following changes:
-
Navigate to Redirect URLs, and add
uikit-example://login
as type Login anduikit-example://signup
as type Sign-up. -
Navigate to OAuth, and set up login for Apple and Google in the Test environment. Follow all the instructions provided in the Dashboard. If you are not interested in OAuth login you can skip this step. However, the Continue with Apple and Continue with Google buttons in this application will not work. NOTE: for this example app’s Apple OAuth config, only Team ID and Application ID fields require real data, the other fields can be stubbed out with fake data.
-
Finally, navigate to API Keys, and copy your
public_token
. You will need this value later on.
On your machine
In your terminal clone the repo and open the Xcode project:
git clone https://github.com/stytchauth/stytch-ios-uikit-example.git
cd stytch-ios-uikit-example
xed UIKitExample/UIKitExample.xcodeproj
Next, replace the YOUR TOKEN
placeholder with your public_token
in HomeViewController.swift. In a production scenario, you might fetch this token from your backend, or embed in a StytchConfiguration.plist file.
Running the app
After completing all the set up steps above the application can be run as normally from Xcode.
You’ll be able to login with SMS OTP, Sign In With Apple, or Google OAuth and see your values from your Stytch User object as well as see how logging out works.
Next steps
This example app showcases a small portion of what you can accomplish with Stytch. Here are a few ideas to explore:
- Add additional login methods like Passwords or Biometrics.
- Take advantage of the SDK’s headless methods and replace the included UI with your own look and feel.
- Use Stytch Sessions to secure your backend.
Get help and join the community
? Stytch community Slack
Join the discussion, ask questions, and suggest new features in our Slack community!
❓ Need support?
Check out the Stytch Forum or email us at support@stytch.com.