llfbandit / app_links

Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
https://pub.dev/packages/app_links
Apache License 2.0
176 stars 68 forks source link

Support for multiple app instances #85

Closed bdlukaa closed 3 months ago

bdlukaa commented 6 months ago

Is your feature request related to a problem? Please describe. My app used to have a functionality to open another window. Basically, it executes the app executable again with parameters and shows the secondary window. This functionality has stopped working on Windows and Linux when I added the app_links plugin (and of course followed the instructions on README):

bool Win32Window::Create(const std::wstring& title,
                                const Point& origin,
                                const Size& size) {
    if (SendAppLinkToInstance(title)) {
        return false;
    }

Destroy();

...

Describe the solution you'd like The current implementation blocks any new windows from being created if there is already a window open. Ideally, the window should be blocked from being created ONLY when the schemes registered are recognized (just like macOS). In any other case, the window should be created normally.

Describe alternatives you've considered n/a

Additional context

llfbandit commented 6 months ago

On windows and Linux, you can modify the setup source code to allow the creation of another window. Just don't return early as stated. Also, you can parse command line if finer grain is needed to whether create new window or not. This package can't do it for you as it would be too late.

bdlukaa commented 6 months ago

On the other platforms (android, iOS, macOS), the developer has to register the schemas on the platform side. If this was the case for Windows and Linux, one app could have multiple instances (opened by the app itself or by the user) running.

bdlukaa commented 6 months ago

On windows and Linux, you can modify the setup source code to allow the creation of another window. Just don't return early as stated.

Yes, this is a possibility. My point is that the other people may not be familiar with the platform side and may face the same issue in the future. The instructions on the README need to be updated with to support multiple app instances. The platform code may need to be updated as well. Something like:

bool Win32Window::Create(const std::wstring& title,
                                const Point& origin,
                                const Size& size) {
    if (SendAppLinkToInstance(title, ['schema', 'schema2'])) { // just a proposal
        return false;
    }

Destroy();

...
YosaRama commented 6 months ago

Hi, I upgrade my flutter to 3.16.4 and my application 'app_link' not working as expected behavior. it will always opening up new windows app instead of doing action after the 'app_link' got access from the browser. is this related with my question?

I see the problems here https://github.com/bluecherrydvr/unity/issues/185, but I'm not really sure my issue is the same with this one. Thanks!