Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save phone verification ID across process deaths #1393

Merged
merged 1 commit into from
Jul 18, 2018
Merged

Save phone verification ID across process deaths #1393

merged 1 commit into from
Jul 18, 2018

Conversation

SUPERCILEX
Copy link
Collaborator

Fixes #1392

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@@ -60,4 +63,14 @@ public void submitVerificationCode(String number, String code) {
PhoneAuthProvider.getCredential(mVerificationId, code),
false)));
}

public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putString(VERIFICATION_ID_KEY, mVerificationId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no issue with this, but just wondering have you seen this pattern of handing the instance state in the ViewModel elsewhere or is this your own invention? Seems a to tie it a little too close to the Activity but I can't think of a reason why it's any worse than having the logic directly in the Activity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked around, but couldn't find sample code with onSaveInstanceState. 😕 So I guess it's time to patent my new invention, right? 😂

I wouldn't mind moving it to the activity, but it made more sense to me to let the ViewModel manage its saved state. (Otherwise, we'd end up with getters and setters for mVerificationId which shouldn't be used outside of the state restoration context.) Whad'ya think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am cool with it, let's just pinky swear not to show Jake Wharton or Yigit the monster we've created!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌😂

@samtstern samtstern merged commit 71fa34a into firebase:version-4.2.0-dev Jul 18, 2018
@SUPERCILEX SUPERCILEX deleted the phone-state-loss branch July 18, 2018 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants