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

Disable the deeplinks from code #52

Closed chiragjuneja closed 7 months ago

chiragjuneja commented 1 year ago

We have the requirement that we want to disable the deeplinks (weblinks) in our app for a particular workflow.

We can precisely identify the scenario when we want to disable the deeplinks temporarily and enable it back. But we could not find way to do it.

On native app, we could do something like this: ComponentName act = new ComponentName(Android.App.Application.Context, "com.company.ActivityForDeeplink");

//enabling Android.App.Application.Context?.PackageManager?.SetComponentEnabledSetting(act, ComponentEnabledState.Enabled, ComponentEnableOption.DontKillApp);

//disabling Android.App.Application.Context?.PackageManager?.SetComponentEnabledSetting(act, ComponentEnabledState.Disabled, ComponentEnableOption.DontKillApp);

But since we are including the library at common code level only, and have no activity for deeplinks explicitly, we could not find the way to do it.

Links were looking to disable are : "http/https://" We want custom urls schemes ,like : "://redirect", to work as expected that app will receive callbacks via handleincominglinks etc.

Does it related to

[ ] App Links (Android)
[ X ] Deep Links (Android)
[ ] Universal Links (iOS)
[ ] or Custom URL schemes? (iOS)

Any idea how to disable or enable the deeplinks at codelevel.

llfbandit commented 1 year ago

This package does not provide such feature. There is no way to do this on app level.

I guess your particular workflow is triggered when you are in foreground and ends also in foreground. So, currently the only way I see is to stop listening to the stream (or filter it) while you are in your known workflow (system events will still be fired though but it should not be an issue).

chiragjuneja commented 1 year ago

@llfbandit : Thanks for the suggestion. By removing the listener, We are not handling the link from the app, but link is still coming to the app and not being handled in browser.

To add the details, We are facing the issue with login workflow. As we want the login to happen in the browser (outside the app), but login workflow tries to load the urls which are candidate for the deeplink and hence open the app without login completion. We want login workflow to be successfully handled in the browser itself.

At the same point, We want only http/https urls to be disabled from the deeplinks, but we expect callback to "custom url schemes" to come to app, as we are handling redirection to app post successful login via custom url scheme.

BullsEye34 commented 10 months ago

@llfbandit : Thanks for the suggestion. By removing the listener, We are not handling the link from the app, but link is still coming to the app and not being handled in browser.

To add the details, We are facing the issue with login workflow. As we want the login to happen in the browser (outside the app), but login workflow tries to load the urls which are candidate for the deeplink and hence open the app without login completion. We want login workflow to be successfully handled in the browser itself.

At the same point, We want only http/https urls to be disabled from the deeplinks, but we expect callback to "custom url schemes" to come to app, as we are handling redirection to app post successful login via custom url scheme.

I am facing the same issue. It was working perfectly until I implemented deep linking in the app. Now, the login flow is messed up. It would be great if the custom URL scheme opens the app exactly where we left off instead of replacing the Navigator stack with "/" or something like that through which the custom URL is called.

llfbandit commented 7 months ago

What you ask is impossible and independent of this package. As far as I know there is no way to disable this, you have to properly setup your patterns to not being reached by the system. Your setup is static (located in the manifest or entitlements) and this is what triggers the opening of the app from the system.

This package is only a bridge from native code to flutter platform to get the link value.