From ac2951479b4458ae55b8e9bbbab9c202a44b637b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 1 Oct 2025 14:55:04 +0800 Subject: [PATCH] :sparkles: App links --- android/app/src/main/AndroidManifest.xml | 6 ++++ ios/Runner/Info.plist | 8 +++++ lib/pods/chat/chat_subscribe.dart | 1 + pubspec.yaml | 2 ++ windows/runner/main.cpp | 44 ++++++++++++++++++++---- 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8d2a595b..74bc08aa 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -51,6 +51,12 @@ + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index bf13e0df..33137916 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -36,6 +36,14 @@ ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER) + + CFBundleTypeRole + Viewer + CFBundleURLSchemes + + solian + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) diff --git a/lib/pods/chat/chat_subscribe.dart b/lib/pods/chat/chat_subscribe.dart index a373e2fc..4b27d589 100644 --- a/lib/pods/chat/chat_subscribe.dart +++ b/lib/pods/chat/chat_subscribe.dart @@ -136,6 +136,7 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier { WebSocketPacket( type: 'messages.unsubscribe', data: {'chat_room_id': roomId}, + endpoint: 'sphere', ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 40ca8f14..63c12be0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -256,4 +256,6 @@ msix_config: identity_name: dev.solian.app msix_version: 3.2.0.0 logo_path: .\assets\icons\icon.png + protocol_activation: solian, https + app_uri_handler_hosts: solian.app capabilities: internetClientServer, location, microphone, webcam diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index 7027ba77..276c9d0b 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -1,19 +1,51 @@ #include #include #include +#include "app_links/app_links_plugin_c_api.h" #include "flutter_window.h" #include "utils.h" +bool SendAppLinkToInstance(const std::wstring& title) { + // Find our exact window + HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", title.c_str()); + + if (hwnd) { + // Dispatch new link to current window + SendAppLink(hwnd); + + // (Optional) Restore our window to front in same state + WINDOWPLACEMENT place = { sizeof(WINDOWPLACEMENT) }; + GetWindowPlacement(hwnd, &place); + + switch(place.showCmd) { + case SW_SHOWMAXIMIZED: + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + break; + case SW_SHOWMINIMIZED: + ShowWindow(hwnd, SW_RESTORE); + break; + default: + ShowWindow(hwnd, SW_NORMAL); + break; + } + + SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); + SetForegroundWindow(hwnd); + // END (Optional) Restore + + // Window has been found, don't create another one. + return true; + } + + return false; +} + int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { - HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"single_instance_example"); - if (hwnd != NULL) - { - ::ShowWindow(hwnd, SW_NORMAL); - ::SetForegroundWindow(hwnd); - return EXIT_FAILURE; + if (SendAppLinkToInstance(L"solian")) { + return EXIT_SUCCESS; } // Attach to console when present (e.g., 'flutter run') or create a