Skip to content

🐛 [firebase_dynamic_links] iOS AppStore and TestFlight installations do not receive a dynamic link on first open #9103

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

Closed
wederchr opened this issue Jul 14, 2022 · 11 comments
Labels
resolution: duplicate This issue or pull request already exists type: bug Something isn't working

Comments

@wederchr
Copy link

wederchr commented Jul 14, 2022

Bug report

Describe the bug
On iOS if the app is installed through a dynamic link (i.e. the user was redirected to the AppStore through a dynamic link and installed it) the app does not receive said dynamic link when it's opened. The method getInitialLink returns null while onLink does not receive any events at all. Of the following four use cases this last one is the only one that doesn't work:

  • Android app is pre-installed -> user clicks on dynamic link -> app receives dynamic link and routes to the correct screen
  • Android app is not installed -> user clicks on dynamic link -> gets redirected to Google Play, installs and opens the app -> app receives dynamic link and routes to the correct screen
  • iOS app is pre-installed -> user clicks on dynamic link -> app receives dynamic link and routes to the correct screen
  • iOS app is not installed -> user clicks on dynamic link -> gets redirected to App Store/ TestFlight, installs and opens the app -> app receives null from getInitialLink and routes to initial route

Steps to reproduce

Steps to reproduce the behavior:

  1. Open https://get.coachbetter.com/ansH on an iOS device
  2. Install the app from AppStore and open it
  3. Login screen (initial route) is displayed

Expected behavior

Instead of the login screen, the registration screen should have been displayed with the information from the deeplink.

Sample project

Unfortunately I cannot provide the real code but I made code snippet that shows how we initialize Firebase and invoke the Firebase Dynamic Links plugin.

Click To Expand
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(const MyApp());
}

class MyApp extends ConsumerStatefulWidget {
  const MyApp({super.key});

  @override
  ConsumerState<ConsumerStatefulWidget> createState() => _MyAppState();
}

class _MyAppState extends ConsumerState<MyApp> {
  final _navigatorKey = GlobalKey<NavigatorState>();

  @override
  void initState() {
    super.initState();
    FirebaseDynamicLinks.instance.getInitialLink().then(_handleDynamicLink);
    FirebaseDynamicLinks.instance.onLink.listen(_handleDynamicLink);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: _navigatorKey,
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Material App Bar'),
        ),
        body: const Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }

  void _handleDynamicLink(PendingDynamicLinkData? linkData) async {
    if (linkData != null) {
      final url = linkData.link;
      if (url.queryParameters['type'] == 'generic-players') {
        _navigatorKey.currentState?.pushNamed('registration');
      }
    }
  }
}

Additional context

We're using a custom domain as you can see above. I have already double checked the following things:

  • Firebase Console: The App Store ID and the Team ID are set to the correct values
  • Google Cloud Console: The iOS API key is configured to have access to the Firebase Dynamic Links API
  • Certificates, Identifiers & Profiles: The provisioning profile has the Associated Domains capability enabled
  • Info.plist: FirebaseDynamicLinksCustomDomains is set to https://get.coachbetter.com
  • Runner.entitlements: com.apple.developer.associated-domains is set to applinks:get.coachbetter.com
  • Debugging the link with ?d=1 shows no (relavant) warning
  • I have cross-checked various existing issues including 🐛 [firebase_dynamic_links] iOS getInitialLink() is null, onLink not called #6913 and no solution proposed was working (through TestFlight)
  • I tried switching to a combo of app_links and firebase_dynamic_links where I used getInitialAppLink and uriLinkStream from app_links to receive dynamic links and getDynamicLink from firebase_dynamic_links to resolve it. The only change is that I now receive the following link on first open after installation by uriLinkStream: com.coachbetter.playerapp://google/link/?request_ip_version=IP_V4&match_message=No%20pre-install%20link%20matched%20for%20this%20device.

For some reason apps installed by a dynamic link redirection to the app store do not receive this dynamic link on first open.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.3.1 21E258 darwin-x64, locale en-CH)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.69.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.17.5
Flutter SDK 3.0.4
coachbetter 2.1.1+211

dependencies:
- chewie 1.3.4 [cupertino_icons flutter provider video_player wakelock]
- collection 1.16.0
- cupertino_icons 1.0.5
- firebase_app_installations 0.1.1+1 [firebase_app_installations_platform_interface firebase_app_installations_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 1.19.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_dynamic_links 4.3.1 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_messaging 11.4.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_riverpod 1.0.4 [collection flutter meta riverpod state_notifier]
- flutter_secure_storage 5.0.2 [meta flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows]
- flutter_switch 0.3.2 [flutter]
- flutter_widget_from_html_core 0.8.5+3 [csslib flutter fwfh_text_style html]
- freezed_annotation 2.0.3 [collection json_annotation meta]
- go_router 3.1.1 [collection flutter flutter_web_plugins logging meta]
- http 0.13.4 [async http_parser meta path]
- intl 0.17.0 [clock path]
- json_annotation 4.5.0 [meta]
- logging 1.0.2
- package_info_plus 1.4.2 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- share_plus 4.0.9 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web]
- shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- tuple 2.0.0 [quiver]
- url_launcher 6.1.4 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- video_player 2.4.5 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]

dev dependencies:
- build_runner 2.1.11 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_gen_runner 4.2.1+1 [flutter_gen_core build collection crypto glob]
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- freezed 2.0.3+1 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation]
- icons_launcher 1.1.9 [args image path universal_io yaml]
- json_serializable 6.2.0 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]

transitive dependencies:
- _fe_analyzer_shared 40.0.0 [meta]
- analyzer 4.1.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- archive 3.3.0 [crypto path]
- args 2.3.1
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 2.3.0 [analyzer async convert crypto glob logging meta path]
- build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 3.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.0.9 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml]
- build_runner_core 7.2.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml]
- built_collection 5.1.1
- built_value 8.3.2 [built_collection collection fixnum meta]
- characters 1.2.0
- charcode 1.3.1
- checked_yaml 2.0.1 [json_annotation source_span yaml]
- clock 1.1.0
- code_builder 4.1.0 [built_collection built_value collection matcher meta]
- color 3.0.0
- convert 3.0.2 [typed_data]
- crypto 3.0.2 [typed_data]
- csslib 0.17.2 [source_span]
- dart_style 2.2.3 [analyzer args path pub_semver source_span]
- dartx 1.1.0 [characters collection crypto meta path time]
- fake_async 1.3.0 [clock collection]
- ffi 1.2.1
- file 6.1.2 [meta path]
- firebase_app_installations_platform_interface 0.1.1+10 [firebase_core flutter meta plugin_platform_interface]
- firebase_app_installations_web 0.1.0+17 [firebase_app_installations_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- firebase_core_platform_interface 4.4.3 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.6.6 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_dynamic_links_platform_interface 0.2.3+6 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 3.5.4 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 2.4.4 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- fixnum 1.0.1
- flutter_gen_core 4.2.1+1 [path yaml mime xml dartx color collection json_annotation dart_style analyzer args pub_semver source_span]
- flutter_secure_storage_linux 1.1.0 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_macos 1.1.0 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_platform_interface 1.0.0 [flutter plugin_platform_interface]
- flutter_secure_storage_web 1.0.2 [flutter flutter_web_plugins flutter_secure_storage_platform_interface js]
- flutter_secure_storage_windows 1.1.2 [flutter flutter_secure_storage_platform_interface]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- frontend_server_client 2.1.3 [async path]
- fwfh_text_style 2.7.3+2 [flutter]
- glob 2.0.2 [async collection file path string_scanner]
- graphs 2.1.0 [collection]
- html 0.15.0 [csslib source_span]
- http_multi_server 3.2.0 [async]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- image 3.2.0 [archive meta xml]
- io 1.0.3 [meta path string_scanner]
- js 0.6.4
- lints 2.0.0
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- mime 1.0.2
- nested 1.0.0 [flutter]
- package_config 2.0.2 [path]
- package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path]
- package_info_plus_macos 1.3.0 [flutter]
- package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface]
- package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface]
- package_info_plus_windows 1.0.5 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.1
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface]
- path_provider_windows 2.0.7 [ffi flutter path path_provider_platform_interface win32]
- petitparser 5.0.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.2 [meta]
- pool 1.5.0 [async stack_trace]
- process 4.2.4 [file path platform]
- provider 6.0.3 [collection flutter nested]
- pub_semver 2.1.1 [collection meta]
- pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml]
- quiver 3.1.0 [matcher]
- riverpod 1.0.3 [collection meta state_notifier]
- share_plus_linux 3.0.0 [share_plus_platform_interface file flutter meta url_launcher]
- share_plus_macos 3.0.1 [share_plus_platform_interface flutter]
- share_plus_platform_interface 3.0.3 [flutter meta mime plugin_platform_interface]
- share_plus_web 3.0.1 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta]
- share_plus_windows 3.0.1 [share_plus_platform_interface flutter meta url_launcher]
- shared_preferences_android 2.0.12 [flutter shared_preferences_platform_interface]
- shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.3.0 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 1.2.2 [analyzer async build dart_style glob meta path source_span yaml]
- source_helper 1.3.2 [analyzer collection source_gen]
- source_span 1.8.2 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- state_notifier 0.7.2+1 [meta]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- time 2.1.1 [clock]
- timing 1.0.0 [json_annotation]
- typed_data 1.3.1 [collection]
- universal_io 2.0.4 [collection crypto meta typed_data]
- url_launcher_android 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface]
- url_launcher_web 2.0.12 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface]
- vector_math 2.1.2
- video_player_android 2.3.6 [flutter video_player_platform_interface]
- video_player_avfoundation 2.3.5 [flutter video_player_platform_interface]
- video_player_platform_interface 5.1.3 [flutter plugin_platform_interface]
- video_player_web 2.0.10 [flutter flutter_web_plugins video_player_platform_interface]
- wakelock 0.6.1+2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows]
- wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.3.0 [flutter meta]
- wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface]
- wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32]
- watcher 1.0.1 [async path]
- web_socket_channel 2.2.0 [async crypto stream_channel]
- win32 2.6.1 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- xml 6.1.0 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]

@wederchr wederchr added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jul 14, 2022
@wederchr wederchr changed the title 🐛 [firebase_dynamic_links] iOS post-installation attribution not working through AppStore and TestFlight 🐛 [firebase_dynamic_links] iOS AppStore and TestFlight installations do not receive a dynamic link on first open Jul 14, 2022
@metajet98
Copy link

metajet98 commented Jul 15, 2022

We faced the same issue, getInitialLink always null when install and open app from AppStore..
Still using regular domain (.page.link)
firebase_dynamic_links: 4.3.1 and 3.0.2 (downgrade when trying to fix)

@darshankawar darshankawar added the triage Issue is currently being triaged. label Jul 15, 2022
@darshankawar
Copy link

Thanks for the report @wederchr
Is your app initialized using flutterfire configure ? If so, can you try to use manual installation of the google services file (GoogleService-Info.plist) and see if using this method, do you get expected behavior ?

Check this issue for your reference: #8926

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 15, 2022
@wederchr
Copy link
Author

Thanks for the report @wederchr
Is your app initialized using flutterfire configure ? If so, can you try to use manual installation of the google services file (GoogleService-Info.plist) and see if using this method, do you get expected behavior ?

Check this issue for your reference: #8926

Actually I already have the google services file in place in addition to using the flutterfire dart configuration. Should I remove the dart config file in this case?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 15, 2022
@darshankawar
Copy link

Thanks for the update. Based on this comment from team member, it indicates that Dart initialization isn't yet completely feasible for all firebase products, so you may try to just keep google services file and see if with it, you get expected behavior or not.

@darshankawar darshankawar added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 15, 2022
@metajet98
Copy link

any update on this issue guys?

@darshankawar darshankawar removed the Needs Attention This issue needs maintainer attention. label Jul 18, 2022
@wederchr
Copy link
Author

@darshankawar I have tried removing the Dart initialization and adding the google services file but getInitialLink still returned null if called in initState of the initial route. However, wrapping the call in a Future.delayed(const Duration(seconds: 1), () {...}); has resulted in getInitialLink returning the expected link. I have yet to deploy to TestFlight to see if this actually fixes the issue described above but until then: Adding a delay of 1s does not seem like a proper solution to me. Is this a known issue?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 18, 2022
@darshankawar
Copy link

Adding a delay of 1s does not seem like a proper solution to me. Is this a known issue?

I haven't come across this solution yet.

Have you already set the custom domain in info.plist file by adding <key>FirebaseDynamicLinksCustomDomains</key> ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 19, 2022
@wederchr
Copy link
Author

Have you already set the custom domain in info.plist file by adding <key>FirebaseDynamicLinksCustomDomains</key> ?

Yes I have. If you check the additional context section of the issue description above you can find a list of things I have already checked/ tried.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 19, 2022
@darshankawar
Copy link

  • iOS app is not installed -> user clicks on dynamic link -> gets redirected to App Store/ TestFlight, installs and opens the app -> app receives null from getInitialLink and routes to initial route

Looking at this scenario wherein the expected behavior doesn't occur, it looks similar to #7546, so please check that and confirm.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 20, 2022
@wederchr
Copy link
Author

wederchr commented Jul 20, 2022

Looking at this scenario wherein the expected behavior doesn't occur, it looks similar to #7546, so please check that and confirm.

This is indeed the exact issue I am facing. I have already tried the workaround using the app_links plugin but it didn't solve the issue. Though I have only tested through TestFlight using the iosFallbackLink (pointing to the TestFlight app). Can you confirm testing dynamic links through TestFlight using the iosFallbackLink parameter should work?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 20, 2022
@darshankawar
Copy link

Let's continue the discussion in original issue for better tracking.
Closing this as a duplicate.

@darshankawar darshankawar closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2022
@darshankawar darshankawar added resolution: duplicate This issue or pull request already exists and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jul 21, 2022
@firebase firebase locked and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate This issue or pull request already exists type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants