Skip to content

FirebaseDynamicLinks.instance.getInitialLink() only works after using a Timer to delay the call #2631

@stephenhuey

Description

@stephenhuey

I'm using

firebase_dynamic_links: 0.5.0+11

and the current version of the FirebaseDynamicLinks.instance.getInitialLink() method does not find the initial link unless I wait 700+ milliseconds to try retrieving it.

I'm referring to the sample code at these 2 links:

https://pub.dev/packages/firebase_dynamic_links

https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_dynamic_links/example/lib/main.dart

Here is what it looks like when I simply add a Timer to the sample code:


  @override
  void initState() {
    super.initState();
    _timerLink = new Timer(const Duration(milliseconds: 700), () {
      print('700 ms later, going to init dynamic links');
      this.initDynamicLinks();
    });
  }

This successfully finds the link, but if I do not use the Timer it does not find the link. To be clear, this is when I do a fresh install of the app on the iPhone after tapping a dynamic link (and it gets automatically copied to the clipboard). For the record, onLink works when I try to open a link while the Flutter app is already running in the background on my iPhone.

flutter doctor -v
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E287, locale en-US)
    • Flutter version 1.17.1 at /Users/stephen/wardrobe/flutter
    • Framework revision f7a6a7906b (13 days ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/stephen/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    ! CocoaPods 1.7.5 out of date (1.8.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade:
        sudo gem install cocoapods

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Connected device (3 available)
    • Nokia 6 1                  • PL2GARM870103356                     • android-arm64 • Android 10 (API 29)
    • iPhone11                     • 00008030-000139113A30802E            • ios           • iOS 13.4.1
    • iPhone SE (2nd generation) • 45D76A5A-C10A-42B7-9753-51B3B0DF66B9 • ios           • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)

! Doctor found issues in 1 category.



Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions