Hi All,
my goal is to have users reset their password directly in my app as opposed to a web page. Currently, I'm struggling to successfully get the user back to my forgot password activity after
they click the URL link in their email.
If I run my mAuth.sendPasswordResetEmail() method
without using the actionCodeSettings and any redirect, the password reset works as expected (resetting the password on a web page):
I setup the following and confirmed that they work:
Dynamic Link in Firebase console using a domain like: xxxx.page.link/resetPassword
(putting this in the browser on my Mac redirects properly to my website (myWebsite.com - demo only).
I also setup the intent in my AndroidManifest.xml file:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="myWebsite.com" android:scheme="http"/>
<data android:host="myWebsite.com" android:scheme="https"/>
</intent-filter>
I tested this inside android studio and it redirects to the proper app screen.
I also tested the Dynamic Link from above in a web browser on my phone and it also correctly opens
the app and redirects it to the proper app screen.
This is where things break down.
Here's my code to use actionCodeSettings to pass my dynamic link to the sendPasswordresetEmail() method:
String url = "https://xxxx.page.link/resetPassword";
ActionCodeSettings settings = ActionCodeSettings.newBuilder()
.setAndroidPackageName(
getPackageName(),
true, /* install if not available? */
null /* minimum app version */)
.setHandleCodeInApp(true)
.setUrl(url)
.build();
mAuth.sendPasswordResetEmail(email, settings)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Email sent.");
hideProgressDialog();
Toast.makeText(ForgotPasswordActivity.this, getString(R.string.alert_passwordResetConfirm),
Toast.LENGTH_SHORT).show();
}
else {
Exception e = task.getException();
Log.w(TAG, "passwordResetRequest:failure " + e.getMessage(), task.getException());
hideProgressDialog();
Toast.makeText(ForgotPasswordActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
});
When I execute the reset using the actionCodeSettings, this is an example URL that I get (which appears to be invalid - note: I redacted sensitive info):
What I find weird is that the
xxxxx.app.goo.gl domain is added to the front of this. It exists on my list of domains in the Dynamic Links console page, but I don't have any dynamic links setup with it, only the one that is formatted like: xxxx.page.link. If I remove the
xxxxx.app.goo.gl domain from the beginning of the path and replace it with: xxxx.page.link/resetPassword then the redirect works.
I'm not sure if this is a bug or what. I haven't been able to narrow this down any farther. Please let me know if you need any further info.
Any help would be greatly appreciated.
Thanks in advance.
Best,
Brian