listen and connect to uni link mobile
Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
parent
d0b9dd9ae7
commit
b1682d5794
@ -1823,11 +1823,16 @@ StreamSubscription? listenUniLinks({handleByFlutter = true}) {
|
||||
final sub = uriLinkStream.listen((Uri? uri) {
|
||||
debugPrint("A uri was received: $uri. handleByFlutter $handleByFlutter");
|
||||
if (uri != null) {
|
||||
if (!isMobile){
|
||||
if (handleByFlutter) {
|
||||
handleUriLink(uri: uri);
|
||||
} else {
|
||||
bind.sendUrlScheme(url: uri.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
handleUriLinkMobile(uri.toString());
|
||||
}
|
||||
} else {
|
||||
print("uni listen error: uri is empty.");
|
||||
}
|
||||
@ -1844,6 +1849,14 @@ enum UriLinkType {
|
||||
rdp,
|
||||
}
|
||||
|
||||
void handleUriLinkMobile(String uri) {
|
||||
var context = Get.context;
|
||||
var uri_id = uri.split("//").last;
|
||||
if (context != null && uri_id.isNotEmpty){
|
||||
connect(context, uri_id);
|
||||
}
|
||||
}
|
||||
|
||||
// uri link handler
|
||||
bool handleUriLink({List<String>? cmdArgs, Uri? uri, String? uriString}) {
|
||||
List<String>? args;
|
||||
|
@ -54,10 +54,12 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
}
|
||||
bool isPeersLoading = false;
|
||||
bool isPeersLoaded = false;
|
||||
StreamSubscription? _uniLinksSubscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_uniLinksSubscription = listenUniLinks();
|
||||
if (_idController.text.isEmpty) {
|
||||
() async {
|
||||
final lastRemoteId = await bind.mainGetLastRemoteId();
|
||||
@ -312,6 +314,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_uniLinksSubscription?.cancel();
|
||||
_idController.dispose();
|
||||
if (Get.isRegistered<IDTextEditingController>()) {
|
||||
Get.delete<IDTextEditingController>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user