0
votes

The firebase_auth package provides userChanges stream that is firing user state events for signing in and out etc..., however, when i delete the user from the console, no events received. The documentation states "The purpose of this API is to allow users to subscribe to all user events without having to manually hydrate app state in cases where a manual reload was required (e.g. updateProfile()...)". I tried to call reload on user to check if it is not deleted from the console ?

  Future<void> init() async {
    await Firebase.initializeApp();
    await FirebaseAuth.instance.currentUser?.reload();
  }

reload method raises an Exception : PlatformException(firebase_auth, com.google.firebase.auth.FirebaseAuthInvalidUserException: There is no user record corresponding to this identifier. The user may have been deleted., {code: user-not-found, additionalData: {}, message: There is no user record corresponding to this identifier. The user may have been deleted.}).

Is there any way to check if user is deleted or not before proceeding ?

1

1 Answers

0
votes

The userChanges stream responds to events that occur within the SDK itself, not general "realtime" events that occur elsewhere. The SDK documentation is a bit misleading on that point - it's not "realtime" like Realtime Database or Firestore. It's more fair to say that it's "reactive" to the change in state of the user, from the perspective of the SDK.

The stream will generate events when the user signs in or out. If the user account is deleted from the console, it will take up to an hour for that to reflect in the SDK, as it will only attempt to "refresh" the user within that period of time. It's not until that refresh happens that the SDK will consider the user "signed out".