Skip to content

🐛 [firebase_dynamic_links] iOS getInitialLink() is null, onLink not called #6913

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
choi-seung-min opened this issue Aug 31, 2021 · 57 comments
Assignees
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot platform: ios Issues / PRs which are specifically for iOS. plugin: dynamic_links Stale Issue with no recent activity type: bug Something isn't working

Comments

@choi-seung-min
Copy link

Bug report

getInitialLink() is null, onLink is not colled on iOS
On Android, both getInitialLink() and onLink called successfully. I can get deep link through those methods.
But on iOS, app does launch with dynamic link but getInitailLink() is null and onLink is not called when app is in background.

Steps to reproduce

Basically, I followed docs from pub.dev https://pub.dev/packages/firebase_dynamic_links.
I generated url prefix with google generated myapp.page.link.
Added Associated Domains applinks:myapp.page.link.
Added Url Types Identifier: Bundle ID, URL Scheme com.example.myapp.

Generating Dynamic Link:

onPressed: () async {
                  String? uid = FirebaseAuth.instance.currentUser?.uid;
                  final DynamicLinkParameters parameters =
                      DynamicLinkParameters(
                    uriPrefix: 'https://myapp.page.link',
                    link: Uri.parse(
                        'https://invite.friends.myapp/invite_from?uid=$uid'),
                    androidParameters: AndroidParameters(
                      packageName: 'com.example.myapp',
                    ),
                    iosParameters: IosParameters(
                      bundleId: 'com.example.myappios',
                      appStoreId: 'store id',
                    ),
                  );
                  final link = await parameters.buildUrl();
                  final shortenedLink = await DynamicLinkParameters.shortenUrl(
                      link,
                      DynamicLinkParametersOptions(
                          shortDynamicLinkPathLength:
                              ShortDynamicLinkPathLength.unguessable));
                  Share.share('invite_message'.tr() + shortenedLink.shortUrl.toString());
                },

Receiving Dynamic Link:

@override
  void initState() {
    super.initState();
    ...
    initDynamicLinks();
  }

  void initDynamicLinks() async {
    FirebaseDynamicLinks.instance.onLink(
        onSuccess: (PendingDynamicLinkData? dynamicLink) async {
      final Uri? deepLink = dynamicLink?.link;

      print('on link deep link');
      print(deepLink);

      if (deepLink != null) {
        String? uid = FirebaseAuth.instance.currentUser?.uid;
        String? ownerUid = deepLink.queryParameters['uid'];
        if (uid != null && ownerUid != null) {
          _inviteCouponBloc
              .add(NewUserInviteCouponEvent(uid: uid, ownerUid: ownerUid));
        }
      }
    }, onError: (OnLinkErrorException e) async {
      print('OnLinkError');
      print(e.message);
      print(e.stacktrace);
    });

    final PendingDynamicLinkData? data =
        await FirebaseDynamicLinks.instance.getInitialLink();
    final Uri? deepLink = data?.link;

    if (deepLink != null) {
      if (widget.isNewUser) {
        String? uid = FirebaseAuth.instance.currentUser?.uid;
        String? ownerUid = deepLink.queryParameters['uid'];
        if (uid != null && ownerUid != null) {
          _inviteCouponBloc
              .add(NewUserInviteCouponEvent(uid: uid, ownerUid: ownerUid));
        }
      }
    }
  }

When i open app through dynamic link with safari, I got these errors.

"iOS handleLink: https://myapp.page.link/?link=https://invite.friends.myapp/invite_from?uid%3D66kWqpCU1ddHfErvtyucOHK3KoI3&apn=com.example.myapp&isi={app store id}&ibi=com.example.myappios&cid=2464839987823306368&_osl=https://myapp.page.link/ryZWzXFzVqY3sjE4A&_fpb=CJsFEPcCGgVrby1rcg==&_cpt=cpit&_iumenbl=1&_iumchkactval=1&_plt=981&_uit=2105&_cpb=1"
2021-08-30 15:31:09.260470+0900 Runner[9221:902508] 8.3.0 - [Firebase/Analytics][IACS023001] Deep Link does not contain valid required params. URL params: {  
    "_cpb" = 1;  
    "_cpt" = cpit;  
    "_fpb" = "CJsFEPcCGgVrby1rcg==";  
    "_iumchkactval" = 1;  
    "_iumenbl" = 1;  
    "_osl" = "https://myapp.page.link/ryZWzXFzVqY3sjE4A";  
    "_plt" = 981;  
    "_uit" = 2105;  
    apn = "com.example.myapp";  
    cid = 2464839987823306368;  
    ibi = "com.example.myappios";  
    isi = app store id;  
    link = "https://invite.friends.myapp/invite_from?uid={uid_string}";  
}

Additional context

My Flutter app's android bundle ID and iOS bundle ID is different.
As there's duplicate ID in appStore, I changed to ex) myapp -> myappios


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale ko-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (7 available)

Flutter dependencies

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

Click To Expand
- app_links 2.2.0 [flutter app_links_platform_interface app_links_web]
- archive 3.1.2 [crypto path]
- cached_network_image 3.1.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- carousel_slider 4.0.0 [flutter]
- connectivity 3.0.6 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web]
- cupertino_icons 1.0.3
- easy_localization 3.0.0 [flutter shared_preferences intl args path easy_logger flutter_localizations]
- extended_nested_scroll_view 3.0.1 [flutter]
- firebase_analytics 8.2.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta]
- firebase_auth 3.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 2.1.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_dynamic_links 2.0.7 [firebase_core flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_bloc 7.0.1 [flutter bloc provider]
- flutter_colorpicker 0.4.0 [flutter]
- flutter_inapp_purchase 5.0.2 [http meta flutter platform]
- flutter_local_notifications 5.0.0+4 [flutter flutter_local_notifications_platform_interface platform timezone]
- flutter_screenutil 5.0.0+2 [flutter]
- flutter_xlider 3.4.0 [flutter]
- fluttertoast 8.0.7 [flutter flutter_web_plugins]
- get_it 7.2.0 [async collection]
- get_version 0.2.2 [flutter package_info]
- google_fonts 2.1.0 [flutter http path_provider crypto]
- google_mobile_ads 0.13.2 [meta flutter]
- google_sign_in 5.0.5 [flutter google_sign_in_platform_interface google_sign_in_web meta]
- http 0.13.3 [async http_parser meta path pedantic]
- image 3.0.2 [archive meta xml]
- in_app_purchase 1.0.6 [flutter in_app_purchase_platform_interface in_app_purchase_android in_app_purchase_ios]
- launch_review 3.0.1 [flutter]
- lottie 1.1.0 [archive characters flutter path vector_math]
- modal_bottom_sheet 2.0.0 [flutter]
- native_filters 0.0.4+alpha [flutter]
- page_transition 2.0.2 [flutter]
- path 1.8.0
- path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- permission_handler 6.1.3 [flutter meta permission_handler_platform_interface]
- photo_view 0.10.3 [flutter]
- share 2.0.4 [meta mime flutter]
- shared_preferences 2.0.6 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- social_share_plugin 0.3.1+1 [flutter meta]
- sqflite 2.0.0+3 [flutter sqflite_common path]
- url_launcher 6.0.9 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- version 2.0.0

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- _fe_analyzer_shared 22.0.0 [meta]
- analyzer 1.7.1 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic]
- app_links_platform_interface 0.1.0 [flutter plugin_platform_interface]
- app_links_web 0.1.0 [flutter flutter_web_plugins app_links_platform_interface]
- args 2.2.0
- async 2.6.1 [meta collection]
- bloc 7.0.0 [meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.0 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.1.0
- charcode 1.2.0
- cli_util 0.3.3 [meta path]
- clock 1.1.0
- collection 1.15.0
- connectivity_for_web 0.4.0 [connectivity_platform_interface flutter_web_plugins flutter]
- connectivity_macos 0.2.0 [flutter]
- connectivity_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- convert 3.0.1 [typed_data]
- coverage 1.0.3 [args logging package_config path source_maps stack_trace vm_service]
- crypto 3.0.1 [collection typed_data]
- easy_logger 0.0.2 [flutter]
- fake_async 1.2.0 [clock collection]
- ffi 1.1.2
- file 6.1.2 [meta path]
- firebase 9.0.1 [http http_parser js]
- firebase_analytics_platform_interface 2.0.1 [flutter meta]
- firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta]
- firebase_auth_platform_interface 6.0.0 [firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 3.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 3.1.0 [collection firebase_core flutter meta plugin_platform_interface]
- flutter_blurhash 0.6.0 [flutter meta pedantic]
- flutter_cache_manager 3.1.2 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_local_notifications_platform_interface 3.0.0 [flutter plugin_platform_interface]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- glob 2.0.1 [async collection file path pedantic string_scanner]
- google_sign_in_platform_interface 2.0.1 [flutter meta quiver]
- google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- http_multi_server 3.0.1 [async]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- in_app_purchase_android 0.1.4+2 [collection flutter in_app_purchase_platform_interface json_annotation meta test]
- in_app_purchase_ios 0.1.3 [collection flutter in_app_purchase_platform_interface json_annotation meta test]
- in_app_purchase_platform_interface 1.1.0 [flutter plugin_platform_interface]
- intl 0.17.0 [clock path]
- io 1.0.3 [meta path string_scanner]
- js 0.6.3
- json_annotation 4.0.1
- logging 1.0.1
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- mime 1.0.0
- nested 1.0.0 [flutter]
- node_preamble 2.0.1
- octo_image 1.0.0+1 [flutter flutter_blurhash]
- package_config 2.0.0 [path]
- package_info 0.4.3+4 [flutter]
- path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 2.0.0 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.1
- permission_handler_platform_interface 3.6.1 [flutter meta plugin_platform_interface]
- petitparser 4.1.0 [meta]
- platform 3.0.0
- plugin_platform_interface 2.0.1 [meta]
- pool 1.5.0 [async stack_trace]
- process 4.2.1 [file path platform]
- provider 5.0.0 [collection flutter nested]
- pub_semver 2.0.0 [collection]
- quiver 3.0.1 [matcher]
- rxdart 0.27.1
- shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- shelf 1.2.0 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 3.0.0 [path shelf shelf_static]
- shelf_static 1.1.0 [convert http_parser mime path shelf]
- shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_map_stack_trace 2.1.0 [path stack_trace source_maps]
- source_maps 0.10.10 [source_span]
- source_span 1.8.1 [collection path term_glyph]
- sqflite_common 2.0.0+2 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- synchronized 3.0.0
- term_glyph 1.2.0
- test 1.16.8 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core]
- test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.3.19 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api]
- timezone 0.7.0 [path]
- typed_data 1.3.0 [collection]
- url_launcher_linux 2.0.0 [flutter]
- url_launcher_macos 2.0.0 [flutter]
- url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface]
- url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface]
- url_launcher_windows 2.0.0 [flutter]
- uuid 3.0.4 [crypto]
- vector_math 2.1.0
- vm_service 6.2.0
- watcher 1.0.0 [async path pedantic]
- web_socket_channel 2.1.0 [async crypto stream_channel]
- webkit_inspection_protocol 1.0.0 [logging]
- win32 2.2.5 [ffi]
- xdg_directories 0.2.0 [meta path process]
- xml 5.1.2 [collection meta petitparser]
- yaml 3.1.0 [collection source_span string_scanner]

@choi-seung-min choi-seung-min added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Aug 31, 2021
@markusaksli-nc markusaksli-nc added the triage Issue is currently being triaged. label Aug 31, 2021
@markusaksli-nc
Copy link
Contributor

Hi @choi-seung-min
Is the bundle id the exact same as your app bundle id? How exactly are you opening the link on the device?
Thank you

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Aug 31, 2021
@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 Aug 31, 2021
@choi-seung-min
Copy link
Author

Hello @markusaksli-nc
The bundle id is copy-pasted from Runner.xcodeproj's Bundle Identifire and AndroidManifest.xml.
I opened app with note, copy-pased from safari and facebook messenger.

note launch url through safari but i changed to open my app directly(long press and select open myapp).
safari launch app but no call back running at all.
messenger open safari with messenger's in app browser

@markusaksli-nc
Copy link
Contributor

So the issue is present if the app is launched when opening the link in safari or in all cases?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Aug 31, 2021
@choi-seung-min
Copy link
Author

choi-seung-min commented Aug 31, 2021

getInitialLink() is null and onLink not calling shows in all case. But the [Firebase/Analytics][IACS023001] log come when opening the link in safari.

@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 Aug 31, 2021
@choi-seung-min
Copy link
Author

When I open link with note(long press the link and select open link in myapp), https://myapp.page.link/someshortenlink Log shows

@choi-seung-min
Copy link
Author

choi-seung-min commented Sep 1, 2021

update

On iOS when i copy and paste generated dynamic link to safari, it shows my app icon and open button. If i click open button, safari show error message Safari cannot open the page because the adress is invalid.. The app was installed. On Android, It works fine. At very first opening link with chrome, It opened play store. But after that, it opens the app.

@markusaksli-nc
Copy link
Contributor

I still haven't been able to reproduce this. It works as expected on both simulator and physical. Could you provide a minimal complete reproducible code sample?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 1, 2021
@choi-seung-min
Copy link
Author

As I followed document of firebase_dynamic_links, there's no more additional code for reproduce this bug except I wrote on first issue log.
Can it be a setting or URL scheme collision? I'm currently using app_links library for iOS only to get custom url scheme for coupon code. identifier: myapp://, URL Scheme: myapp.

If it's not result of url scheme, please check if I forgot something to do for iOS setting.

  1. create url prefix in firebase console with google provided domain(https://myapp.page.link)
  2. enabled Associated Domains with my url prefix applinks:myapp.page.link
  3. add URL Scheme in the Info tab.
  4. As I'm not using custom domain, I didn't write FirebaseDynamicLinksCustomDomains values (I tryed after add this value but It didn't work)
  5. I call FirebaseDynamicLinks.instance.onLink and FirebaseDynamicLinks.instance.getInitialLink() in main page which comes after splash page.

Additionally, I figured some kind of work around with app_links library.
With firebase, I couldn't run any function which work with dynamic links, as I cant get any url.
But, the app_link works fine with android and gives me long link like https://myapp.page.link/?link=https://invite.friends.myapp/invite_from?uid%3D66kWqpCU1ddHfErvtyucOHK3KoI3&apn=com.example.myapp&isi={app store id}&ibi=com.example.myappios&cid=2464839987823306368&_osl=https://myapp.page.link/ryZWzXFzVqY3sjE4A&_fpb=CJsFEPcCGgVrby1rcg==&_cpt=cpit&_iumenbl=1&_iumchkactval=1&_plt=981&_uit=2105&_cpb=1
So I can get this link=https://invite.friends.myapp/invite_from?uid%3D66kWqpCU1ddHfErvtyucOHK3KoI3 by get Uri.queryParameters.

But this cause exception with dynamic route with flutter.

@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 Sep 1, 2021
@markusaksli-nc
Copy link
Contributor

markusaksli-nc commented Sep 2, 2021

If you set up the URL Type correctly

Set the Identifier field to a unique value and the URL Schemes field to be your bundle identifier, which is the default URL scheme used by Dynamic Links.

then you should have done everything necessary for the links to work. The reason I asked for a minimal complete sample is to exclude any other plugins to see if it reproduces on its own and to see if you are calling the listeners correctly.

Could you also provide your Podfile just in case?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 2, 2021
@choi-seung-min
Copy link
Author

I'm little confused. as you said

URL Schemes field to be your bundle identifier, which is the default URL scheme used by Dynamic Links.

I have different bundle id with iOS and Android. And my Dynamic link is based on android's bundle id.
Do i have to fix my URL Scheme field to Android's bundle id?

My Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '12.1'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
              config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
              config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
                '$(inherited)',

                ## dart: PermissionGroup.calendar
                'PERMISSION_EVENTS=0',

                ## dart: PermissionGroup.reminders
                'PERMISSION_REMINDERS=0',

                ## dart: PermissionGroup.contacts
                'PERMISSION_CONTACTS=0',

                ## dart: PermissionGroup.camera
                'PERMISSION_CAMERA=0',

                ## dart: PermissionGroup.microphone
                'PERMISSION_MICROPHONE=0',

                ## dart: PermissionGroup.speech
                'PERMISSION_SPEECH_RECOGNIZER=0',

                ## dart: PermissionGroup.photos
                'PERMISSION_PHOTOS=0',

                ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
                'PERMISSION_LOCATION=0',

                ## dart: PermissionGroup.notification
                'PERMISSION_NOTIFICATIONS=1',

                ## dart: PermissionGroup.mediaLibrary
                'PERMISSION_MEDIA_LIBRARY=0',

                ## dart: PermissionGroup.sensors
                'PERMISSION_SENSORS=0',

                ## dart: PermissionGroup.bluetooth
                'PERMISSION_BLUETOOTH=0'
              ]
            end
  end
end

@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 Sep 2, 2021
@markusaksli-nc
Copy link
Contributor

Your podfile looks fine. What do you mean by your dynamic link being based on the android bundle id? If you mean that is the bundle id you specified when you generated it then this might just be solved if you generate a dynamic link with the Apple bundle id?

This is why you are presented with the option to specify the bundle id when you generate the dynamic link. The bundle id plays a role in how the generated link is used by the target platform.

@badrobot15
Copy link

I suggested that the iOS tag be removed from the pubdev page of dynamic links as it is misleading.

As a workaround, on iOS we use app_links and parsed the short url that comes in. So we embedded parameters in that to parse and execute code accordingly. It's not the best solution but a patchy work-around if you are against the clock

@russellwheatley
Copy link
Member

Hey folks, dynamic links API has changed quite a bit since the major version update which you can see in the changelog here.

I have tested on my device (iOS 14) and getInitialLink() works fine. I'd be grateful if anyone has tried on other versions and could confirm their experience in this channel 🙏

@ggirotto
Copy link

ggirotto commented Dec 22, 2021

I've tested in iOS simulator and it's working as expected!

Update: Working as expected in physical iOS device as well.

@FBisca
Copy link

FBisca commented Dec 22, 2021

I couldn't make it work even with the 4.0.3, not receiving the initialLink and neither on the stream.

I'm still using a mix of AppLinks and FirebaseDynamicLinks.instance.getDynamicLink.

I've also added the DynamicLinks.performDiagnostics(completion: nil) to the Swift code so I couldn't see what was missing and everything seems fine.

@badrobot15
Copy link

@russellwheatley @ggirotto yes the new update works fine for when the app is already installed on phone. However, it still fails for production apps i.e. apps on the AppStore. For whatever reason, when the user is redirected to the appstore to install the app, after install the link is no longer detected by getInitialLink(). Opened a issue on #7546.

@kightsonsanom
Copy link

@russellwheatley I have tested this on physical iPhone 12 Pro, iOS 15.0.2 and I couldn't get a link from getInitialLink nor an event from onLink stream. It works fine on any Android device.

Using 4.0.3 dynamic_links version and manual firebase configuration.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.1 20G224 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] Connected device (3 available)

• No issues found!

@ggirotto you said that I've tested in iOS simulator and it's working as expected!, how is it possible if release mode does not work on Simulators and in dynamic links example it states:

iOS also requires you run in release mode to test dynamic links ("flutter run --release").

?

@ggirotto
Copy link

@ggirotto you said that I've tested in iOS simulator and it's working as expected!, how is it possible if release mode does not work on Simulators and in dynamic links example it states:

iOS also requires you run in release mode to test dynamic links ("flutter run --release").

?

Good catch. unfortunately my Mac is under repair. As soon as I get it back I add my points to this thread.

@lesnitsky lesnitsky removed their assignment Jan 4, 2022
@ggirotto
Copy link

ggirotto commented Feb 8, 2022

Now that my app finally is in production, I can say that the feature is working as expected to me. The deep links are correctly being opened and their metadata is being injected in the UI (in my case, I'm using to share referral codes in deep-links)

@russellwheatley
Copy link
Member

@ggirotto, thanks for the report.

@kightsonsanom, have you tried adding this property to your Info.plist file? Be sure to change the domain to the one you're using for your dynamic link. Let me know how it goes.

@ggirotto
Copy link

ggirotto commented Feb 8, 2022

@russellwheatley We added this property to the plist pointing to our custom domain, and it's working as expected.

I'm not sure what others are facing when they find errors during the usage, but for me the plugin is working as expected.

@ghost
Copy link

ghost commented Feb 9, 2022

Same thing as @kightsonsanom. I'm practicaly copied example and it's not working. Any updates?

@russellwheatley
Copy link
Member

Hey @bs-vasyl-trs, I'd go over your setup with a fine toothcomb. Be sure to read the setup for Apple or Android in the docs as there are a few moving pieces.

As noted above, it works for me and @ggirotto.

@russellwheatley russellwheatley added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Feb 10, 2022
@ComplexCarbos
Copy link

I am experiencing a similar problem on iOS clicking a dynamic link when the app is not running. Works fine on Android. I believe whats happening is that getInitialLink() is returning null, but then 'X' number of milliseconds later onLink.listen() fires with the link information, which creates a race condition.

Adding a one second wait right before the call to getInitialLink appears to be a viable workaround.

await Future.delayed(const Duration(seconds: 1));
_dynamicLinkData ??= await FirebaseDynamicLinks.instance.getInitialLink();

I am using firebase_dynamic_links: 4.0.6
I'm compiling against iOS 11.4

[✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-x64, locale en-US)
[✗] Android toolchain - develop for Android devices
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.49.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

@ggirotto
Copy link

But assuming that the dynamic_link may come from both places (getInitialLink and onLink.listen), it shouldn't matter where it comes from. If the problem is a race condition between both methods, one of them isn't well configured. The problem would be if neither of them fire or both fire with the same information.

@ComplexCarbos
Copy link

Perhaps I'm doing something incorrectly then.

If getInitialLink returns null, I navigate to what is essential a home screen. If either get initiallink, or listem return data, I navigate to a "special" screen that displays the link content. What seems to be happening in this:

  • App is not running
  • User clicks a dynamic link.
  • The app starts and then opens
  • getInitialLink() is called, but returns null, which starts the process of loading the default home screen
  • Before the above completes onLink.listen() fires.
  • onLink.listen() retrieves the the link information and starts the flow to navigate to the special link screen.
  • In most cases, onLink.listen() completes first; the flow started by getInitialLink() completes second

Ultimately, when the app is not running the dynamic link correctly starts the app and the link screen loads. But then a second or two later, it is automatically replaced by the default home screen.

@kightsonsanom
Copy link

@russellwheatley thanks for the input. I do have custom domain setup and I was missing Info.plist details that you've mentioned. At the moment I am still not able to get anything from onLink.listen but I think this is due to our faulty firebase.json setup. Unfortunately I am not able to work on it right now, I will provide more input as soon as I get back to it.

@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Mar 8, 2022
@google-oss-bot
Copy link

Hey @choi-seung-min. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@choi-seung-min if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@rosenstrauch
Copy link

many thanks to #6913 (comment) for a working workaround to this annoying problem which totally still persists.

@damianoct
Copy link

I also wasted two entire days figuring things to work and I want to share with you what fixes the issue.

Although the #6913 (comment) workaround actually works (as of now you need to slightly change the code because of new version of app_link library), you can avoid to use app_link library with the following steps:

  • Locate the API_KEY you are using every time you call a Firebase service. If you are a flutterfire user you can easily check the apikey in the auto generated firebase_option.dart file.
  • go to the Google Cloud Console
  • choose the relevant project (i.e. the project you use for your application)
  • open the menu and go to APIs & Services -> Credentials
  • click Edit API key for the API key in question
  • scroll down to API restrictions
  • from the dropdown, choose Firebase Installations API
  • click Save
    wait a couple of minutes for Google servers to update and retry...

this is my situation for the iOS key:

image

image

Now the onLink() should be triggered when the app is in foreground state and you click a dynamic link and the getInitialLink() function should correctly return a non null link if the app was open (from a background state) with a dynamic link.

At the end it seems the application cannot successfully resolve the link because of an unauthorized call against FirebaseService.

Hope this helps.

@john7ric
Copy link

I also wasted two entire days figuring things to work and I want to share with you what fixes the issue.

Although the #6913 (comment) workaround actually works (as of now you need to slightly change the code because of new version of app_link library), you can avoid to use app_link library with the following steps:

  • Locate the API_KEY you are using every time you call a Firebase service. If you are a flutterfire user you can easily check the apikey in the auto generated firebase_option.dart file.
  • go to the Google Cloud Console
  • choose the relevant project (i.e. the project you use for your application)
  • open the menu and go to APIs & Services -> Credentials
  • click Edit API key for the API key in question
  • scroll down to API restrictions
  • from the dropdown, choose Firebase Installations API
  • click Save
    wait a couple of minutes for Google servers to update and retry...

this is my situation for the iOS key:

image

image

Now the onLink() should be triggered when the app is in foreground state and you click a dynamic link and the getInitialLink() function should correctly return a non null link if the app was open (from a background state) with a dynamic link.

At the end it seems the application cannot successfully resolve the link because of an unauthorized call against FirebaseService.

Screenshot 2022-04-11 at 1 51 50 PM

Hope this helps.

My APi key is not restricted , but still not getting the onLink callback

@firebase firebase locked and limited conversation to collaborators Apr 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot platform: ios Issues / PRs which are specifically for iOS. plugin: dynamic_links Stale Issue with no recent activity type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests