-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[firebase_dynamic_links] Change architecture to work correctly on async links and launch links #1687
Conversation
f8d9022 to
916f07b
Compare
916f07b to
3ff2d4d
Compare
6a75249 to
5f2057b
Compare
collinjackson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Some minor comments, @bparrishMines might want to take a look as well.
|
Hi @jherencia, I'm unable to reproduce these bugs with the latest version of |
|
Hello @bparrishMines, This PR had two goals:
I've made another PR to firebase_messaging (#1709) in the same direction. |
|
Hi @bparrishMines, I assume you didn't have time to see this. Do you know when you'll be able to check this, I'm going to be off in some days and to be able to answer your questions. I really think this is a really important improvement. |
|
@jherencia Unfortunately, this plugin is still lacking integration testing and we are still working on our side to potentially get expresso to work with flutter testing tools (e.g. flutter driver). Since '1.' has already been solved, I don't believe we should go forward with an architecture change without integration tests to make sure everything will still work. Also, we typically want the dart api to match the native api. The Android API doesn't use a stream to receive links, so I don't believe an architecture change is necessary if it isn't necessary to solve a bug or crash. |
|
Thank you @bparrishMines for the response, I'm going to try explain why I think this PR is needed even if we do not have integration tests.
As easy as: which follows how Firebase library works in the native part: but the current architecture requires the Dart application to listen to to AppLifecycleChanges, which adds a lot of complexity and risks of failure in the Dart side. Why? It should not be that hard to retrieve the dynamic link. And it wouldn't be necessary to call retrieveDynamicLink every time the application state changes.
I did this using a Future following the best practices used in other plugins and in this one.
So I understand why not having integration tests could be a blocker, but I think asking developers to subscribe to app lifecycle changes and to use an inconsistent API is blocker too, as long as makes their life hard and increases the risk of bugs and edge cases in which the "dynamic link" is not syncronized between the native part and the dart part, which has happened a lot in the past and lead to "not so" elegant solutions like: bc04a77#diff-3f6c424218a2662c8ddc4b322f30bf66 Please, do not miss understand my comment, I understand the hard work behind this but I'm just trying to point that it could me improved with this PR. I'm happy to make any changes that you think could be better. Best regards. |
|
Thanks for taking the time to write this out. I agree with your reasoning and believe this feature should be implemented. However, I think it should be implemented as a convenience method rather than an architecture change. I could imagine an instance where someone would only want to retrieve a single dynamic link, and not want to listen for callbacks. For example, email link authentication. Not to mention some users may currently be using Would it be possible to keep the current architecture and add the listener? I also think an LMK what your thoughts on this are. |
|
Since this plugin is pre-1.0 I am assuming some breaking changes are acceptable. We may be able to draw some inspiration from the React Native Firebase implementation here. It looks like they have two ways that they allow developers to receive links:
Interestingly errors aren't passed over the bridge. They're simply logged to the console. https://github.com/invertase/react-native-firebase/blob/978b298f94940db7776cd6c4117eb6b618c92824/packages/links/ios/RNFBLinks/RNFBLinksAppDelegateInterceptor.m#L74 In the Dart version,
FYI @Ehesp |
|
Yes, the architecture proposed is based in RNFirebase.
I am happy to do any change you think is needed: change the naming, migrate from See https://github.com/flutter/plugins/tree/master/packages/firebase_messaging and my other PR (#1709) @bparrishMines RNFirebase does this exact thing:
The PR follows the same architecture. |
packages/firebase_dynamic_links/lib/src/firebase_dynamic_links.dart
Outdated
Show resolved
Hide resolved
|
@jherencia After giving this more thought, I think we should go through with the change and avoid depending on the Lifecycle changes. I left an initial review with a few comments |
…e between the dynamic link which opened the app and links clicked on app active or in background.
b91e1b3 to
d2c0a79
Compare
d2c0a79 to
5fa9cb3
Compare
|
Great news :). I pushed two commits:
I haven't migrated from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jherencia. Sorry for the delay, I've been out sick this week. I left a few more comments. Also, I agree that we can wait for a switch to EventChannel since it won't affect the developer; like @collinjackson mentioned.
bparrishMines
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@collinjackson do you have any more input?
collinjackson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a mild preference to call the API getInitialLink instead of getLaunchLink for consistency with React Native Firebase and because the internal Firebase API review has approved the getInitialLink method name. If you feel that getLaunchLink is better, let me know and we can re-evaluate the decision, but otherwise I think we should use getInitialLink.
a66d43c to
b3bb0ee
Compare
…base_dynamic_links
|
I've changed the name as suggested. Thank you both :) |
…nc links and launch links (flutter#1687) * [firebase_dynamic_links] Changed architecture to be able to difference between the dynamic link which opened the app and links clicked on app active or in background. * [firebase_dynamic_links] Improvements provided by @bparrishMines * [firebase_dynamic_links] Renaming configure to onLink * [firebase_dynamic_links] Renaming getLaunchLink to getInitialLink
|
thanks for help me to solve my issue |
…nc links and launch links (flutter#1687) * [firebase_dynamic_links] Changed architecture to be able to difference between the dynamic link which opened the app and links clicked on app active or in background. * [firebase_dynamic_links] Improvements provided by @bparrishMines * [firebase_dynamic_links] Renaming configure to onLink * [firebase_dynamic_links] Renaming getLaunchLink to getInitialLink
Description
This pull request changes firebase_dynamic_links architecture to be able to difference between the dynamic link which opened the app and links clicked on app active or in background.
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?