2

I'm following this guide, I'm having this code:

var acs = ActionCodeSettings(
  url: 'https://example.com/auth/widget',
  androidPackageName: 'com.example',
  iOSBundleId: 'com.example',
  handleCodeInApp: true,
  androidInstallApp: true,
  androidMinimumVersion: '12',
);

var emailAuth = 'john.doe@pm.me';
FirebaseAuth.instance
    .sendSignInLinkToEmail(
        email: emailAuth, actionCodeSettings: acs)
    .catchError((onError, stackTrace) {})
    .then((value) =>
        print('Successfully sent email verification'));

Sending the email works, but when I click on the email, then…

  • in iOS it opens https://example.com/auth/widget - which is the fallback
  • in Android it shows a circular loader for about 1s and then it "falls down" and nothing happens

The incoming link handler

FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
    print('got dynamic link! $dynamicLinkData');
}).onError((error) {
    print('error error!');
});

I configured dynamic links in Firebase to point to to.example.com. I also added a manual dynamic link to.example.com/test which opens my app (the got dynamic link! message shows up) - so all seems fine, the problem seems to lie in the link generation.

The link structure I get by email is:

https://to.example.com/?link=https://example-abcd.firebaseapp.com/__/auth/action?apiKey…%26continueUrl%3Dhttps://example.com/auth/widget%26lang%3Den&apn=com.example&amv=12&ibi=com.example&ifl=https://example-abcd.firebaseapp.com/__/auth/action?apiKey%3D…%26continueUrl%3Dhttps://example.com/auth/widget%26lang%3Den

hansaplast
  • 11,007
  • 2
  • 61
  • 75

1 Answers1

0

After some more painful hours of debugging and reading documentation I finally found it out. Most of this is in the flutter documentation, but since the documentation has broken links and is a bit all over the place it was hard for me to catch it all!

Android

I needed to decrease the androidMinimumVersion from 12 to 1. Then my app opens and I can receive the dynamic link. No idea why. My android simulator is android version 13 but the app never opened.

Before decreasing the android version I also set the sha256 setting in firebase, using gradlew signingReport documented in this answer. Not sure though this was required.

iOS

I forgot to do all the steps documented in receiving links on iOS section, namely:

  1. add the dynamic links domain into associated domains
  2. add FirebaseDynamicLinksCustomDomains into Info.plist

Overall, I found that to get this feature working was really really hard for me as a Flutter beginner. But I guess a lot of the setup I can re-use as the dynamic links capability seems to be something which comes in handy in the future.

hansaplast
  • 11,007
  • 2
  • 61
  • 75