@@ -20,6 +20,8 @@ import com.google.firebase.auth.AuthCredential
2020import com.google.firebase.auth.AuthResult
2121import com.google.firebase.auth.FirebaseUser
2222import com.google.firebase.auth.MultiFactorResolver
23+ import com.google.firebase.auth.PhoneAuthCredential
24+ import com.google.firebase.auth.PhoneAuthProvider
2325
2426/* *
2527 * Represents the authentication state in Firebase Auth UI.
@@ -252,6 +254,74 @@ abstract class AuthState private constructor() {
252254 override fun toString (): String = " AuthState.EmailSignInLinkSent"
253255 }
254256
257+ /* *
258+ * Phone number was automatically verified via SMS instant verification.
259+ *
260+ * This state is emitted when Firebase Phone Authentication successfully retrieves
261+ * and verifies the SMS code automatically without user interaction. This happens
262+ * when Google Play services can detect the incoming SMS message.
263+ *
264+ * @property credential The [PhoneAuthCredential] that can be used to sign in the user
265+ *
266+ * @see PhoneNumberVerificationRequired for the manual verification flow
267+ */
268+ class SMSAutoVerified (val credential : PhoneAuthCredential ) : AuthState() {
269+ override fun equals (other : Any? ): Boolean {
270+ if (this == = other) return true
271+ if (other !is SMSAutoVerified ) return false
272+ return credential == other.credential
273+ }
274+
275+ override fun hashCode (): Int {
276+ var result = credential.hashCode()
277+ result = 31 * result + credential.hashCode()
278+ return result
279+ }
280+
281+ override fun toString (): String =
282+ " AuthState.SMSAutoVerified(credential=$credential )"
283+ }
284+
285+ /* *
286+ * Phone number verification requires manual code entry.
287+ *
288+ * This state is emitted when Firebase Phone Authentication cannot instantly verify
289+ * the phone number and sends an SMS code that the user must manually enter. This is
290+ * the normal flow when automatic SMS retrieval is not available or fails.
291+ *
292+ * **Resending codes:**
293+ * To allow users to resend the verification code (if they didn't receive it),
294+ * call [FirebaseAuthUI.verifyPhoneNumber] again with:
295+ * - `isForceResendingTokenEnabled = true`
296+ * - `forceResendingToken` from this state
297+ *
298+ * @property verificationId The verification ID to use when submitting the code.
299+ * This must be passed to [FirebaseAuthUI.submitVerificationCode].
300+ * @property forceResendingToken Token that can be used to resend the SMS code if needed
301+ *
302+ */
303+ class PhoneNumberVerificationRequired (
304+ val verificationId : String ,
305+ val forceResendingToken : PhoneAuthProvider .ForceResendingToken ,
306+ ) : AuthState() {
307+ override fun equals (other : Any? ): Boolean {
308+ if (this == = other) return true
309+ if (other !is PhoneNumberVerificationRequired ) return false
310+ return verificationId == other.verificationId &&
311+ forceResendingToken == other.forceResendingToken
312+ }
313+
314+ override fun hashCode (): Int {
315+ var result = verificationId.hashCode()
316+ result = 31 * result + forceResendingToken.hashCode()
317+ return result
318+ }
319+
320+ override fun toString (): String =
321+ " AuthState.PhoneNumberVerificationRequired(verificationId=$verificationId , " +
322+ " forceResendingToken=$forceResendingToken )"
323+ }
324+
255325 companion object {
256326 /* *
257327 * Creates an Idle state instance.
0 commit comments