ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
11.8k stars 993 forks source link

[Bug]: Custom URL schemes are not intercepted on Android (capacitor v6) #7630

Closed AlexandrosGounis closed 2 weeks ago

AlexandrosGounis commented 2 weeks ago

Capacitor Version

6.1.2

Other API Details

npm -v output: 10.2.3
node -v output: v20.10.0

Platforms Affected

Current Behavior

We want to support both Android App Links ("https" scheme) and custom urls for deep linking. The "https" works as expected but the custom url scheme is not intercepted on Android. We have included a custom scheme in strings.xml as follows:

<string name="custom_url_scheme">myapp</string>

And in AndroidManifest.xml:

<data android:scheme="@string/custom_url_scheme" />

we have also tried:

<data android:scheme="myapp" />

However, when we redirect to myapp://foo from another Android app or webpage, we are not redirected to the capacitor App

Expected Behavior

Both App Links and custom urls should work, like in v5.

Project Reproduction

(private repository)

Additional Information

No response

ionitron-bot[bot] commented 2 weeks ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙

AlexandrosGounis commented 2 weeks ago

We found out what was causing this issue and we think it is important to point that out in the docs. When both Universal Links and custom URL schemes are defined, they need to be in separate <intent-filters>. This is because capacitor by default includes an android:autoVerify="true" in its main intent-filter, and custom schemes will not be intercepted unless they are defined in a separate <intent-filter>, without autoVerify. We believe this is a nuance worth mentioning in the docs.