[iOS] Authenticate Using Apple with Firebase

Tram Ho

Introduce

In the previous article , I and you learn how to log in using Apple ID in the iOS app. And recently, Google’s Firebase has a beta support for Sign in With Apple in Firrebase Authentication, and in this article we will implement how to configure and implement Authenticate Using Apple on iOS using Firebase.

Authenticate Using Apple on iOS With Firebase

Before you begin

To log in using Apple, we first need to configure Sign In with Apple on Apple’s developer site, then enable sign-in with Apple in your Firebase project.

Sign in with Apple and authenticate with Firebase

Have you reviewed the article and created the same project.

To authenticate with an Apple account, first use the AuthenticationServices framework to log in the user to the Apple account, then use the ID token from Apple’s response to create a Firebase AuthCredential object:

Generate randomNonceString :

Create Sign in With Apple Button:

Handle ASAuthorizationControllerDelegate:

After Sign in with Apple And Authenticate with Firebase is successful, on Firebase Authentication you will register an email with the format [email protected] . And the system absolutely can not know the user’s real email, ensuring maximum safety for users.

Conclude

Above we together learn and make a simple example to perform Sign in with Apple and Authenticate with Firebase, we wait for the final release and can apply to our project. Thank you for reading the article

Reference: Firebase

Demo

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo