Links

Apple Sign-In

Apple Sign-In allows users to authenticate using their Apple Accounts.
Apple sign-in functionality is only supported for iOS.
Apple sign-in

Prerequisites

Before getting started with this section, ensure you have:
  1. 1.
    Completed all steps in the Firebase Setup.
  2. 2.
    Completed Initial setup required for authentication. (Please note: Skip if you have already enabled authentication and created a 'users' collection while creating your project with Firebase Setup.)
  3. 3.
    Created an Apple account.
  4. 4.
    Purchased an Apple Developer membership. Please see this link for more details on the Apple Developer program and how to sign up.
  5. 5.
    Apple sign-In can not be tested in Run Mode. You will need to test it on a real device or emulator.

Adding Apple sign-in

Adding Apple sign-in comprises of the following steps:

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

2. Enabling Apple sign-in in Firebase

To enable Apple authentication in the Firebase:
  1. 1.
    Open the Firebase console and click on Authentication.
  2. 2.
    Click on the Get started button (this may not be visible if you have already set up other forms of Authentication).
  3. 3.
    Select the Sign-in method tab.
  4. 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. 5.
    Find the Apple switch and enable it.
  6. 6.
    Click on the Save button.

3. 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:

4. 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. 1.
    Select the widget (e.g., Button) on which you want to add the action.
  2. 2.
    Select Actions from the properties panel (the right menu) and select Add Action.
  3. 3.
    Search and select the Log in (under Backend/Database > Firebase Authentication) action.
  4. 4.
    Set Auth Provider to Apple.
  5. 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.

5. Adding logout action

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

6. Configure project in Xcode

Before you test the app, you must download the code and 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. 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. 2.
    In Xcode, click on Runner (left side menu) and then select the Signing and Capabilities tab.
  3. 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. 4.
    Under the Signing section, find the Team dropdown and select your team.

7. Verify user creation

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.
Verify user creation

Last Updated Date: August 25, 2023