Merge pull request #6266 from sahilyeole/feat/mobile_uni_link

Feat: mobile uni link support (android + ios)
This commit is contained in:
RustDesk 2023-11-04 10:59:29 +08:00 committed by GitHub
commit 6a281fb7ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 3 deletions

View File

@ -61,6 +61,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Intent for deep linking-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="rustdesk" />
</intent-filter>
</activity>
<activity
@ -81,4 +89,4 @@
android:value="2" />
</application>
</manifest>
</manifest>

View File

@ -24,6 +24,21 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLIconFile</key>
<string></string>
<key>CFBundleURLName</key>
<string>com.carriez.rustdesk</string>
<key>CFBundleURLSchemes</key>
<array>
<string>rustdesk</string>
</array>
</dict>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>

View File

@ -1955,6 +1955,7 @@ bool handleUriLink({List<String>? cmdArgs, Uri? uri, String? uriString}) {
List<String>? urlLinkToCmdArgs(Uri uri) {
String? command;
String? id;
final options = ["connect", "play", "file-transfer", "port-forward", "rdp"];
if (uri.authority.isEmpty &&
uri.path.split('').every((char) => char == '/')) {
return [];
@ -1962,18 +1963,33 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
// For compatibility
command = '--connect';
id = uri.path.substring("/new/".length);
} else if (['connect', "play", 'file-transfer', 'port-forward', 'rdp']
.contains(uri.authority)) {
} else if (options.contains(uri.authority)) {
final optionIndex = options.indexOf(uri.authority);
command = '--${uri.authority}';
if (uri.path.length > 1) {
id = uri.path.substring(1);
}
if (isMobile && id != null) {
if (optionIndex == 0 || optionIndex == 1) {
connect(Get.context!, id);
} else if (optionIndex == 2) {
connect(Get.context!, id, isFileTransfer: true);
}
return null;
}
} else if (uri.authority.length > 2 && uri.path.length <= 1) {
// rustdesk://<connect-id>
command = '--connect';
id = uri.authority;
}
if (isMobile){
if (id != null){
connect(Get.context!, id);
return null;
}
}
List<String> args = List.empty(growable: true);
if (command != null && id != null) {
args.add(command);

View File

@ -156,6 +156,7 @@ void runMobileApp() async {
await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]);
gFFI.userModel.refreshCurrentUser();
runApp(App());
await initUniLinks();
}
void runMultiWindow(

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