🐛 [firebase_dynamic_links] iOS getInitialLink() is null, onLink not called
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]
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
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
So the issue is present if the app is launched when opening the link in safari or in all cases?
getInitialLink() is null and onLink not calling shows in all case. But the [Firebase/Analytics][IACS023001] log come when opening the link in safari.
When I open link with note(long press the link and select open link in myapp), https://myapp.page.link/someshortenlink Log shows
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.
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?
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.
- create url prefix in firebase console with google provided domain(https://myapp.page.link)
- enabled
Associated Domainswith my url prefixapplinks:myapp.page.link - add
URL Schemein theInfotab. - As I'm not using custom domain, I didn't write
FirebaseDynamicLinksCustomDomainsvalues (I tryed after add this value but It didn't work) - I call
FirebaseDynamicLinks.instance.onLinkandFirebaseDynamicLinks.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.
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?
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
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.
Then, Do I have to make 2 different url prefix if my iOS and Android bundle id is different?
My iOS and Android bundle ids are different because I cannot upload my iOS app due to duplicate bundle id(maybe same id have been uploaded earlier). So I changed my iOS bundle id.
I wrote down my bundle ids properly when i generate dynamic links. Like:
androidParameters: AndroidParameters(
packageName: 'com.example.myapp',
),
iosParameters: IosParameters(
bundleId: 'com.example.myappios',
appStoreId: 'appStoreID',
),
Well if you specified the bundle ids properly when you generated the link I'm not sure what could be causing this at this point. Labeling this for some further investigation.
Thanks for help :)
I am facing the same issue. It appears to be caused by another plugin. I read somewhere that webview on cordova causes this issue. Could this be the same in flutter? I have webview in my pubspec.yaml. Still haven't found a solution to this issue. It happens only on iOS.
dependencies: animated_theme_switcher: ^1.0.9 auto_search: ^1.0.6 avatar_glow: ^1.2.0 awesome_dialog: ^1.2.1 basic_utils: ^3.5.0 cached_network_image: ^3.1.0 circular_countdown_timer: ^0.0.4 cloud_firestore: 2.5.1 connectycube_sdk: ^2.0.2 contacts_service: ^0.6.1 country_code_picker: ^1.6.2 country_currency_pickers: ^1.0.1 cupertino_icons: ^1.0.0 currency_picker: ^1.0.3 dio: ^4.0.0 dio_http_cache: ^0.3.0 dropdown_search: ^0.4.8 edge_alert: ^0.0.1 feature_discovery: ^0.14.0 firebase_analytics: 8.2.0 firebase_auth: 3.1.0 firebase_core: 1.6.0 firebase_dynamic_links: 2.0.7 firebase_messaging: ^10.0.6 firebase_storage: 10.0.3 flutter: sdk: flutter flutter_countdown_timer: ^4.1.0 flutter_expanded_tile: ^0.2.1 flutter_google_places: ^0.3.0 flutter_icons: ^1.1.0 flutter_local_notifications: ^8.1.1 flutter_paystack: ^1.0.4+1 flutter_polyline_points: ^0.2.4 flutter_signin_button: ^1.1.0 flutter_siri_suggestions: ^1.0.2+hotfix1 flutter_sound: ^8.3.4 flutter_speed_dial: ^3.0.5 flutter_stripe: ^1.3.0 flutter_svg: ^0.22.0 flutter_tts: ^2.0.0 fluttertoast: ^7.1.6 geocoder: ^0.2.1 google_fonts: ^2.1.0 google_maps_flutter: ^2.0.6 google_place: ^0.4.3 google_sign_in: ^5.0.7 google_speech: ^2.0.1 group_radio_button: ^1.0.1 highlight_text: ^0.7.2 image_cropper: ^1.3.1 image_picker: ^0.8.4 line_awesome_icons: ^1.0.4+2 liquid_progress_indicator: ^0.3.2 location: ^4.3.0 lottie: ^1.1.0 maps_launcher: ^2.0.0 modal_progress_hud: ^0.1.3 permission_handler: ">=5.1.0+2 <=8.1.4" platform_device_id: ^1.0.1 progress_indicators: ^0.1.5 provider: ">=5.0.0 <=6.0.0" qr_flutter: ^4.0.0 random_string: ^2.1.0 recase: ^4.0.0 rflutter_alert: ^1.1.0 rx_shared_preferences: ^2.1.0 scan: ^1.0.0 screenshot: ^1.2.3 searchfield: ^0.3.0 share: ^2.0.4 shared_preferences: ">=0.5.6+1 <=2.0.7" simple_speed_dial: ^0.1.2 slide_button: ^0.2.9 slider_button: ^1.0.0 sound_stream: ^0.2.0 speech_to_text: ^5.0.0 stacked: ^2.2.5 strings: ^0.1.2 table_calendar: ^2.3.3 uni_links: ^0.4.0 timeago: ^3.1.0 url_launcher: ^6.0.2 uuid: ^3.0.4 velocity_x: ^3.3.0 video_player: ^2.1.15 webview_flutter: ^2.0.2
@nejifresh It's not a perfect solution but, there's workaround for this issue. You can use app_link package to get your deep link for the app. It seems deep link arrives to app but firebase couldn't detect it.
I can't get it to work on an iOS device, but it works on the simulator with xcrun openurl. On the device it opens the app but the url is null.
I've tried iOS 14.8 and 15.0 on the device. It was working before I upgraded flutter and I XCode to the latest.
<key>CFBundleURLName</key>
<string>links.my.domain</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
packages:
bot_toast: ^4.0.1 catcher: ^0.6.8 cloud_firestore: ^2.5.1 csv: any cupertino_icons: ^1.0.3 dart_geohash: ^2.0.1 dart_json_mapper: ^2.1.2 dart_json_mapper_flutter: ^2.0.1 dart_json_mapper_mobx: ^2.0.5 disposable_object: ^2.0.0 firebase_auth: ^3.1.0 firebase_core: ^1.6.0 firebase_dynamic_links: ^2.0.10 firebase_messaging: ^10.0.6 firebase_storage: 10.0.1 flutter_mobx: ^2.0.2 flutter_spinbox: ^0.5.2 get_it: ^7.2.0 http: any icons_helper: any material_design_icons_flutter: 5.0.5955-rc.1 mobx: ^2.0.4 shared_preferences: ^2.0.5 syncfusion_flutter_charts: ^19.1.59 timeago: ^3.0.2
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?
What works? Is there a public example that works?
Dynamic links definitely aren't working now on iOS, and this is critical because many apps probably use them for users to log in. I'm going to use app_links for now.
I suspect its due to either the recent updates to Flutter or XCode or the invertase firebase build. The Flutter or XCode update forced updating to invertase firebase 8.6.0 -> 8.7.0.
I tried my code at an old commit where links once worked. That required me to change to invertase firebase 8.7.0 to compile. After compiling, that code doesn't work anymore.
I'm not pasting my full source, but my app's use of firebase_dynamic_links is contained to the following class. Also note I'm using invertase/firestore-ios-sdk-frameworks - see Podfile below. My pubspec is above.
I replaced firebase_dynamic_links with app_links as you can see below, and it worked without any other changes, so my other code and configuration is correct.
AppDynamicLinks.dart firebase_dynamic_links version - handleFirebaseDynamicLinksGlobal doesn't fire on iphone in debug mode
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
typedef OnLinkCallback = Future<dynamic> Function(Uri uri);
class AppDynamicLinks {
static String LINKS_DOMAIN = 'links.mydomain.co';
static List<OnLinkCallback> _successListeners = List<OnLinkCallback>.empty(growable: true);
static Uri? _initialLink;
static Uri? get initialLink => _initialLink;
static bool _initialisedAuthDeepLinks = false;
// can call this multiple times without harm
static Future<void> setup() async {
if (_initialisedAuthDeepLinks)
return;
_initialisedAuthDeepLinks = true;
Uri? dl = (await FirebaseDynamicLinks.instance.getInitialLink())?.link;
print("initial link ${dl?.toString()}");
if (dl!=null) {
_initialLink = dl;
for (var l in _successListeners)
await l(dl);
}
FirebaseDynamicLinks.instance.onLink(
onSuccess: handleFirebaseDynamicLinksGlobal,
onError: (OnLinkErrorException e) async {
print('OnLinkErrorException');
print(e.message);
}
);
}
static Future<dynamic> handleFirebaseDynamicLinksGlobal(PendingDynamicLinkData? dynamicLink) async {
print("handleFirebaseDynamicLinksGlobal");
print("dynamicLink ${dynamicLink?.link.toString()}");
if (dynamicLink==null)
return;
var repeatOfInitial = _initialLink!=null && dynamicLink.link.toString() == _initialLink!.toString();
if (_initialLink==null)
_initialLink = dynamicLink.link;
if (!repeatOfInitial)
for (var l in _successListeners)
await l(dynamicLink.link);
}
static ensureListener(OnLinkCallback cb) {
if (_successListeners.contains(cb))
return;
_successListeners.add(cb);
}
static removeListener(OnLinkCallback cb) {
if (!_successListeners.contains(cb))
return;
_successListeners.remove(cb);
}
static bool isFirebaseAuthLink(Uri uri) {
return uri.path.startsWith('__/auth/');
}
}
AppDynamicLinks.dart app_links version - handleFirebaseDynamicLinksGlobal does fire on iphone in debug mode
import 'package:app_links/app_links.dart';
typedef OnLinkCallback = Future<dynamic> Function(Uri uri);
class AppDynamicLinks {
static String LINKS_DOMAIN = 'links.mydomain.co';
static List<OnLinkCallback> _successListeners = List<OnLinkCallback>.empty(growable: true);
static Uri? _initialLink;
static AppLinks? _appLinks;
static Uri? get initialLink => _initialLink;
static bool _initialisedAuthDeepLinks = false;
// can call this multiple times without harm
static Future<void> setup() async {
if (_initialisedAuthDeepLinks)
return;
_initialisedAuthDeepLinks = true;
_appLinks = AppLinks(
onAppLink: (Uri uri, String stringUri) {
handleFirebaseDynamicLinksGlobal(uri);
},
);
Uri? dl = await _appLinks!.getInitialAppLink();
print("initial link ${dl?.toString()}");
if (dl!=null) {
_initialLink = dl;
for (var l in _successListeners)
await l(dl);
}
}
static Future<dynamic> handleFirebaseDynamicLinksGlobal(Uri link) async {
print("handleFirebaseDynamicLinksGlobal");
print("dynamicLink ${link.toString()}");
var repeatOfInitial = _initialLink!=null && link.toString() == _initialLink!.toString();
if (_initialLink==null)
_initialLink = link;
if (!repeatOfInitial)
for (var l in _successListeners)
await l(link);
}
static ensureListener(OnLinkCallback cb) {
if (_successListeners.contains(cb))
return;
_successListeners.add(cb);
}
static removeListener(OnLinkCallback cb) {
if (!_successListeners.contains(cb))
return;
_successListeners.remove(cb);
}
static bool isFirebaseAuthLink(Uri uri) {
return uri.path.startsWith('__/auth/');
}
}
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '12.3'
# add pods for desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
# 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!
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.7.0'
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['IPHONEOS_DEPLOYMENT_TARGET'] = '12.3'
config.build_settings['ENABLE_BITCODE'] = 'YES'
end
end
end
This should be a top priority for the dev team, since the core function of this package firebase_dynamic_links appears to not be working at all on iOS.