EasyApp

Apple Login/Email Login

Learn how EasyAppSwiftUI project integrates Apple Login/Email Login

Set up Apple Sign In (Recommended)

We recommend you use Apple Sign In. Compared to traditional registration and login processes, Apple Sign In provides a better overall user experience. of course, if you don't plan to use Apple Sign In, you can skip this step.

Configure Apple Sign In

First, make sure you have an available Apple Developer account. If you haven't registered yet, please refer to the official documentation to register. After registration, log in to your developer account and go to the Identifiers page, click the + button

Step 1: Register Services ID

Identifiers addIdentifiers

Select Services IDs and click the Continue button

ServicesIDs

Description can be named using your app name + Services ID.

Identifier is recommended to be named as bundleID.ServicesID. Where bundleID is your app's unique identifier.

Click the Continue button

RServicesIDs

You can find bundleID in your Xcode project here. XcodeBundleID

Click the Register button registerIdent

After completion, return to the Identifiers page and click the Services IDs we just created

successRegisterIdent

If you can't find the Services IDs we just created, filter as shown below filterIdns

Enable Sign in with Apple function and click the Configure button configIdns

In the popup window, you need to configure the following options:

Please replace SUPABASE_PROJECT_ID with your Supabase project ID. You can find it here findSupabaseProjectID

In the documentation example, our SUPABASE_PROJECT_ID is mutkgdbrerijqhqccalu.

  1. In Primary App ID, select your App's Bundle Identifier from the dropdown.
  2. In the Domains and Subdomains field, enter supabase.co,SUPABASE_PROJECT_ID.supabase.co
  3. In the Return URLs field, enter https://SUPABASE_PROJECT_ID.supabase.co/auth/v1/callback
  4. Click the Next button and Done button

WebAuthConfig

Click the Continue button and click the Save button

saveWebAuthConfig saveWebAuthConfig2

Step 2: Create .p8 Authentication Key for Apple Sign In

Go to the Keys page and click the + button

CreateKeys

  1. Enter your Key Name, for easier identification later, we recommend naming it with your app name + Keys.
  2. Select Sign in with Apple function and click the Configure button.
  3. After clicking the Configure button, select your App ID from the Primary App ID dropdown.
  4. Click the Save button RNewKey CKeys

Then click the Continue button and click the Register button

NewKeyCon

NewKeyReg

Step 3: Integrate Apple Sign In with Supabase

Go to your Supabase project, click the sidebar Authentication, click Sign In/Providers, click the Apple button. SupabaseSignApple

In the popup window, you need to configure the following information:

  1. Enable Enable Sign in with Apple function
  2. In the Client IDs field, enter your Services ID and your app's unique identifier bundleID. (separated by commas, no spaces) AppleModalSave

The Secret Key (for OAuth) field can be left empty.

  1. Click save

Forgot Services ID and bundleID? No problem, let's review again.

  1. On the Identifiers page, find the Services IDs we just created. successRegisterIdent

  2. In your Xcode project, find Bundle Identifier. XcodeBundleID

Or on the Identifiers page, you can also find it IdensBIds

Step 4: Test Apple Sign In

Apple Sign In testing needs to be done on a real device.

Go back to the Supabase console and check the Users table, you can see the user information from your Apple Sign In.

SignAppleSuccess

Congratulations πŸŽ‰πŸŽ‰πŸŽ‰, you have successfully integrated the Apple Sign In function.

Support Email Verification Function

Supabase enables email authentication by default, and EasyApp of course supports it. But you need to configure Deep Linking. The configuration process is very simple.

  1. Set URL Type in Xcode

urlType

In the screenshot, you need to fill in identifier and URL Schemas

  • identifier is recommended to use Bundle Identifier.
  • URL Schemas is recommended to use your App name.
  1. Configure Deep Linking in Supabase

Next, go to the Supabase Authentication page and click the URL Configuration button. urlConfirm

Click the Add URL button and enter your App's URL.

When filling in Deep Linking, we recommend using the format YourAppName://user?type=sign_up.

Let me explain why we set it up this way, where user represents the module name, type represents the type, and sign_up represents email verification. The user module has the following types:

  • sign_up: email verification
  • reset_password: password reset

So we use type to distinguish.

In SwiftUI, we distinguish through module name + type.

.onOpenURL { url in
  let value = url.getEaspAppDeepLinkUrlParam(hostKey: "user", name: "type")
  guard value == "reset_password" else { return }

  /// Handle password reset logic
}
.onOpenURL { url in
  let value = url.getEaspAppDeepLinkUrlParam(hostKey: "user", name: "type")
  guard value == "sign_up" else { return }

  /// Handle email verification logic
}

Add URL filling rules: URL Schemas + ://

The EasyApp template has already configured the email verification/password reset Deep Linking rules. You need to configure identifier and URL Schemas in Xcode. Then configure Deep Linking in your Supabase as shown in the figure.

If you have other needs later, just follow this rule to configure

At this point, you can normally use Email authentication function.

Process: User registration successful -> Supabase sends email -> User clicks link in email -> Directly returns to the App -> Login successful.

  1. Resend verification email

For user experience, we have made the following optimizations:

  • After successful user registration, assuming the user does not verify the email in time, when they reopen the app at some point, we will check whether the current user has verified the email If the user has not verified the email, we will prompt the user to verify the email.

So we provide a VerifyEmailView

This component will automatically pop up when the user has not verified the email and supports users to resend verification emails.

The Supabase platform provides a default email sending service for you to try. This service is limited to 2 emails per hour and only provides best-effort availability. For production use, we recommend configuring a custom SMTP server. For specific operation guidelines, please refer to Custom SMTP Configuration Guide

Disable Email Verification Function

If you don't plan to use Email authentication function, you can disable them. email emailNoComfirm

If you disable the email verification function, after user registration is completed, to optimize the shortest login process: we will let the user log in directly successfully.

Next, we will configure App In-App purchase

Last updated on