listen and connect to uni link mobile

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
Sahil Yeole 2023-11-02 02:13:33 +05:30
parent d0b9dd9ae7
commit b1682d5794
2 changed files with 20 additions and 4 deletions

View File

@ -1823,10 +1823,15 @@ StreamSubscription? listenUniLinks({handleByFlutter = true}) {
final sub = uriLinkStream.listen((Uri? uri) {
debugPrint("A uri was received: $uri. handleByFlutter $handleByFlutter");
if (uri != null) {
if (handleByFlutter) {
handleUriLink(uri: uri);
} else {
bind.sendUrlScheme(url: uri.toString());
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;

View File

@ -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>();