Skip to main content

Apple Login

Apple Sign-In allows users to authenticate using their Apple Accounts.

Support

Apple sign-in functionality is only supported for iOS.

Prerequisites

Before getting started with this section:

  1. Complete Firebase Setup.
  2. Complete Initial setup required for authentication.
  3. Created an Apple account.
  4. Purchased an Apple Developer membership. Read more about the Apple Developer Program and how to sign up.
  5. Apple sign-In can not be tested in Run Mode. You will need to test it on a real device or emulator. Try with Local Run!

Adding Apple sign-in

Adding Apple sign-in comprises of the following steps:

  1. Configure email communication
  2. Enable Apple sign-in in your App ID
  3. Enabling Apple sign-in in Firebase
  4. Add an Apple sign-in button
  5. Add login action
  6. Adding logout action
  7. Preparing to test the app
  8. Verify user creation

1. Configure email communication

"Apple sign-in" is a privacy-focused authentication system. One of its notable features is the ability to hide a user's real email address when signing up for apps and services. When users choose to hide their email, you get one random email address that forwards to the user's actual Apple ID email. This helps users keep their real email addresses private.

User opting to hide the email address

So, in order to contact such users, you must register email sources that your organization will use for communication.

info

Also, If you use any of the Firebase Authentication features that send emails to users, including email link sign-in, email address verification, etc., you must add noreply@YOUR_FIREBASE_PROJECT_ID.firebaseapp.com as well.

To register email sources:

  1. From your Apple developer account, open the Certificates, Identifiers & Profiles page and select services.
  2. Under the 'Sign in with Apple for Email Communication,' click on the Configure button.
  3. Click on the (+) button on the right side of Email Sources.
  4. Enter the email in the Email Addresses section and click Next.
  5. Now click on Register and then the Done button.

2. Enable Apple sign-in in your App ID

Here's how you do it:

  1. From your Apple developer account, open the Identifiers section.
  2. Open the identifier with your existing APP ID.
  3. Select Sign In with Apple from the list.
  4. Click Save.

3. Enabling Apple sign-in in Firebase

To enable Apple authentication in the Firebase:

  1. Open the Firebase console and click on Authentication.
  2. Click on the Get started button (this may not be visible if you have already set up other forms of Authentication).
  3. Select the Sign-in method tab.
  4. Click on Apple (Under the 'Additional Providers' section). If you have already added any other provider, click on the Add new provider and then click on Apple.
  5. Find the Apple switch and enable it.
  6. Click on the Save button.

4. Add an Apple sign-in button

To allow users to authenticate, you need a login page with a button. You can create your own or use the one from the widget template or page template.

Here's how you can add the Apple sign-in button from our page template:

5. Add login action

When you click the Apple sign-in button, it will trigger the 'Log In' action, prompting users to provide their Apple ID credentials.

To add login action:

  1. Select the widget (e.g., Button) on which you want to add the action.
  2. Select Actions from the Properties Panel (the right menu) and select Add Action.
  3. Search and select the Log in (under Backend/Database > Firebase Authentication) action.
  4. Set Auth Provider to Apple.
  5. Tick the Create User Document and set the Collection to users. After successful login, this will insert the user's email address into the 'users' collection. If a user already exists, it won't add details again.

6. Adding logout action

To let users log out of your app, you can use the Logout action.

7. Preparing to test the app

For testing your app on a real device, you must configure the project in Xcode. This includes adding a team to your project and setting an appropriate signing certificate.

Here's how you configure your project in Xcode:

  1. Open your project in Xcode. If you are using Android Studio, right-click on the ios folder, find Flutter, and then click on the Open iOS module in Xcode.
  2. In Xcode, click on Runner (left side menu) and then select the Signing and Capabilities tab.
  3. We recommend choosing the Automatically manage signing option. This will auto-create the profiles, app ID, and certificates required to build and run your app. If you don't, you'll have to manually create a 'provisioning profile' and then add it in the Xcode.
  4. Under the Signing section, find the Team dropdown and select your team.

8. Verify user creation

Run and test your app. To confirm the successful integration of Apple authentication and the creation of users, navigate to your Firebase project > Authentication > Users and check the user entries.