Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Deep linking for Chromebook Android (App appUrlOpen) #2065

Open
thmclellan opened this issue Mar 25, 2024 · 0 comments
Open

[Feature] Deep linking for Chromebook Android (App appUrlOpen) #2065

thmclellan opened this issue Mar 25, 2024 · 0 comments
Labels
type: feature request A new feature, enhancement, or improvement

Comments

@thmclellan
Copy link

thmclellan commented Mar 25, 2024

Feature Request

Capacitor's App plugin's deep linking with appUrlOpen events works well for standard Android, but it seems the addListener appURLOpen event is never triggered when the Android app is running on Chromebook. This was causing issues for some deep linking flows where our user authenticates through OAuth using a Browser.open() flow, which on completion returns the user to the app through an app link (com.domain.app://etc).

The root cause is that Android Chromebook app links trigger an intent of org.chromium.arc.intent.action.VIEW instead of the standard Intent.ACTION_VIEW. This causes the AppPlugin's handleOnNewIntent function to ignore the intent, see AppPlugin.java L126:

if (!Intent.ACTION_VIEW.equals(action) || url == null) {
)

There's some great background and a MainActivity.java workaround for this at facebook/react-native#20301.

Possible Solutions

  1. Capacitor App plugin could be extended to handle org.chromium.arc.intent.action.VIEW intents
  2. Override MainActivity onNewIntent() and getIntent() to convert org.chromium.arc.intent.action.VIEW intents into standard ACTION_VIEW intents

Current Workaround

We've done option 2 with the below overrides in our app's MainActivity.java and it's working well. It would be nice to see either of the above options in a future Capacitor update. In any case, I wanted to share this workaround for anyone else trying to do deep linking for Android Chromebook users.

    @Override
    public Intent getIntent() {
        Intent intent = super.getIntent();
        if (intent!=null && intent.getAction().equals("org.chromium.arc.intent.action.VIEW")) {
            return new Intent(intent).setAction(Intent.ACTION_VIEW);
        }
        return intent;
    }

    @Override
    public void onNewIntent(Intent intent) {
        if (intent!=null && intent.getAction().equals("org.chromium.arc.intent.action.VIEW")) {
            super.onNewIntent(new Intent(intent).setAction(Intent.ACTION_VIEW));
        } else {
            super.onNewIntent(intent);
        }
    }

Additional Details

These results are on a Lenovo Chromebook Duet, Chrome OS 120, Android version 11 and Capacitor Android 5.0.7.

@ionitron-bot ionitron-bot bot added the triage label Mar 25, 2024
@IT-MikeS IT-MikeS added type: feature request A new feature, enhancement, or improvement and removed triage labels Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request A new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

2 participants