Open timrijckaert opened 5 years ago
Hi,
I wonder why the distinction was made between receiving values in the background and foreground.
Now you have to check if the initial deeplink was not null.
final initialLink = await getInitialLink(); if (initialLink != null) { ... }
As well as also listen on the stream when a deeplink was received in the foreground.
getLinksStream().listen(...)
We implemented a simple wrapper inside our app which deals with this. Only exposes 1 stream where all events are posted including the initial one.
I wondered if it was something you'd be interested in to include in the lib already?
The helper class itself.
import 'dart:async'; import 'package:rxdart/rxdart.dart'; import 'package:uni_links/uni_links.dart'; /// Adds a wrapper around the uni_links library. class DeepLinkHelper { StreamSubscription<String> _deepLinkStreamSubscription; final BehaviorSubject<String> _deepLinkSink = BehaviorSubject(); Stream<String> get deepLinkStream => _deepLinkSink.stream; DeepLinkHelper() { _postInitialLink(); _deepLinkStreamSubscription = getLinksStream().listen(_deepLinkSink.add); } void _postInitialLink() async { try { final initialLink = await getInitialLink(); if (initialLink != null) { _deepLinkSink.add(initialLink); } } finally {} } void dispose() { _deepLinkStreamSubscription.cancel(); } }
@timrijckaert You have a example of use for this class? Thanks
Like I said, we use it as one gateway of all things deeplink and it has been working perfectly so far.
Please provide an example.
Hi,
I wonder why the distinction was made between receiving values in the background and foreground.
Now you have to check if the initial deeplink was not null.
As well as also listen on the stream when a deeplink was received in the foreground.
We implemented a simple wrapper inside our app which deals with this.
Only exposes 1 stream where all events are posted including the initial one.
I wondered if it was something you'd be interested in to include in the lib already?
The helper class itself.