I want to use Firebase email link authentication in my iOS (Flutter) app with a custom domain:
The app requests Firebase Auth backend to send an email to the user. -- works
The user clicks a link in the email and is taken back to the app. -- works
The app processes the payload of that link to perform the sign in. -- does not work
Firebase Dynamic Links do work in general but the link from that particular Firebase auto-generated email is not. Technically the app is brought to foreground but the Firebase Dynamic Link onLink callback is not fired. I tracked it down to one tiny trailing slash that is missing in the email's link URL:
https://link.mydomain.com?link=https://app.mydomain.com/__/auth/action?apiKey=... (not working)
https://link.mydomain.com/?link=https://app.mydomain.com/__/auth/action?apiKey=... (works)
-------------------------^
To work around this I tried to add a path suffix to my domain but this gave the same results:
https://link.mydomain.com/app?link=https://app.mydomain.com/__/auth/action?apiKey=... (not working)
https://link.mydomain.com/app/?link=https://app.mydomain.com/__/auth/action?apiKey=... (works)
-----------------------------^
The worst part of this difference that made it so hard to find is that if you copy the link on iOS or long press it to see a preview, the slash is just silently added in the right place! You can paste the link to the notes app, click it, and it works!
Only when viewing the email's source code you can see that it is actually not there:
When requesting the link, I call FirebaseAuth.instance.sendSignInWithEmailLink with these params set:
url: 'https://app.mydomain.com',
dynamicLinkDomain: 'link.mydomain.com',
The dynamicLinkDomain param does not accept a protocol or path.
Does anybody know how to...
- make Firebase add this slash to the link when sending the mail?
or
- make Firebase Dynamic Link's
onLinkcallback react to clicked links that do not have a trailing slash?
For reference
My Info.plist contains this key:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://link.mydomain.com</string>
</array>
My entitlements file contains this key:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:link.mydomain.com</string>
</array>
apple-app-site-association (https://link.mydomain.com/apple-app-site-association):
{
"applinks": {
"apps": [],
"details": [{
"appID": "XYZ.com.mydomain.app",
"paths": [
"NOT /_/*",
"/*"
]
}]
}
}
