We all know that social media login is used to authenticate users in a faster way in comparison to a normal login. Most of the popular social login are available like Facebook, Google, Twitter, etc. work as a social login. In this blog, you’ll learn about how apple login works in android to authenticate users in the android applications.
Apple login has two-factor authentication which improves the security of our application and is faster compared to a normal login. We will require a verification code on our trusted device and trusted mobile number when we sign in with an apple id and need a verification code to sign in with your Apple ID.
Prerequisite:
We know that we are doing an apple login with firebase so we require firebase integration in our application so the below step is required to integrate firebase. We require you to add dependency in the app-level Gradle build file and register your project on firebase.
implementation 'com.google.firebase:firebase-auth:19.3.2'
Use Apple Developer Account to register with apple and your apple id generate.
Use that apple credentials login with https://developer.apple.com/account/resources this link and after you show.
Associate your website to your app.
Select authentication from the sidebar and select apple using this you need to press the save button.
private fun initAppleSignIn() {
val provider = OAuthProvider.newBuilder("apple.com")
provider.scopes = arrayOf("email", "name").toMutableList()
provider.addCustomParameter("locale", "en")
val auth: FirebaseAuth = FirebaseAuth.getInstance()
val pending = auth.pendingAuthResult
pending?.addOnSuccessListener { authResult ->
//success
}?.addOnFailureListener { e ->
logA("Apple addOnFailureListener -> " + e.message)
}
auth.startActivityForSignInWithProvider(this@ActivityLogin, provider.build())
.addOnSuccessListener { authResult ->
// Sign-in successful!
val user = authResult.user
val abc= user!!.providerData[1]
if (abc.uid != "") {
id=abc.uid
}
if (!user!!.displayName.isNullOrEmpty()) {
userName = user!!.displayName!!
}else{
userName=""
}
if (user!!.email != "") {
mail= user!!.email!!
}
// logA("Apple Sign In Success -> “
}
.addOnFailureListener { e ->
// logA("Apple Sign In Fail -> " + e.message)
e.printStackTrace()
}
}
You notice that you will get a null value for email and name after sign in because in apple login you only get the user data once on the first sign in with apple.
You need to save the required credentials you received on the first attempt.
I would like to conclude this blog is used for two-factor authentication which improves the security of our application and is more confidential to user’s data and faster compared to a normal login. Kotlin offers a modern and powerful language alternative for Android app development.
User full name, email id, apple id received.
Yes, in the android device when you press the apple login button you go to the web view of the apple website where you need to enter your apple id and password after you successfully register with apple.
To sign in with Apple you need to enter your apple id and password.
Yes, please go to this website https://support.apple.com/en-us/HT202667 and update it.
Yes, you can use the same apple id on many devices.
Diving deep into SwiftUI This blog post drops us into…
Corporate efficiency and customization are vital in today's fast-paced world,…
Flutter Codemagic CI/CD makes your Flutter app build, test, and…
This website uses cookies.