-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 6.0.0
@capacitor/core: 6.0.0
@capacitor/android: 6.0.0
@capacitor/ios: 6.0.0
Installed Dependencies:
@capacitor/cli: 6.0.0
@capacitor/core: 6.0.0
@capacitor/ios: 6.0.0
@capacitor/android: 6.0.0
[success] iOS looking great! 👌
[success] Android looking great! 👌
Other API Details
`npm --version`
> 10.7.0
`node --version`
> v20.11.0
Platforms Affected
- iOS
- Android
- Web
Current Behavior
After redirecting to an external URL that is allowed in the server.allowNavigation
config setting, an android app reports being on a web platform instead of android.
This can be seen by calling Capacitor.getPlatform()
(which returns android
before redirecting and web
after redirecting) or by trying to use a native API, which will either fallback to the web version of the API, or fail to run at all
All this works on iOS, where after redirecting, the app can still use native iOS APIs
Expected Behavior
After redirecting, the android app should still have access to all the native Android APIs (and report itself as being an Android platform)
Project Reproduction
https://github.com/Dylancyclone/capacitor-android-redirect/tree/main
Additional Information
Reproduction details are in the repo, but the basic reproduction steps are as follows:
- Serve a valid capacitor app on your computer (i.e. with
npx serve .
) - Add your computer's IP to the
server.allowNavigation
capacitor config setting - Load the application on your (real or simulated) device
- Notice that
Capacitor.getPlatform()
returnsandroid
on android andios
on iOS - Redirect to the hosted server (any method works, can be
window.location.assign()
,window.location.href = ""
,window.location.replace()
, or redirecting through a form - Notice that
Capacitor.getPlatform()
now returnsweb
on android but stillios
on iOS
Possibly related to #5455
Here are videos showing the issue. Even though these were recorded on a simulator, the results are identical to a physical device
android.mov
ios.mov
Our use case is to have one app that connects to different backends on different subdomains, very similar to Slack. So far everything is working except the android app loses access to its native APIs