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

URL Bar Visible on Additional Trusted Origin Domain in PWA APK #855

Open
parsaM110 opened this issue Jun 18, 2024 · 2 comments
Open

URL Bar Visible on Additional Trusted Origin Domain in PWA APK #855

parsaM110 opened this issue Jun 18, 2024 · 2 comments

Comments

@parsaM110
Copy link

I'm experiencing an issue with my PWA where the URL bar is not behaving as expected across different domains. Here's the setup:

  • My PWA is hosted on: https://app.domain.com
  • My SSO (Keycloak) is hosted on: https://sso.domain.com

Problem

When accessing the PWA on https://app.domain.com, the URL bar is hidden as expected. However, when the PWA navigates to https://sso.domain.com for SSO purposes, the URL bar becomes visible. I want the URL bar to remain hidden on both domains.

Configuration

  1. Asset Links:

    • Both app.domain.com and sso.domain.com have the same assetlinks.json file with no-cache cache control, and they are accessible.
    • The assetlinks.json file includes the necessary entries for both domains.
  2. HTML Head:

    • On https://sso.domain.com, I have included the following in the <head> section:
      <link rel="assetlinks.json file" href="https://sso.domain.com/.well-known/assetlinks.json">

Issue

Despite following the steps outlined above, the URL bar remains visible on https://sso.domain.com. I am unsure what might be wrong with the SSO additional trusted origin configuration.

Request

Could you please help me identify what might be causing this issue or guide me on any additional steps I might need to take to resolve it?

Additional Information

Let me know if there is any more information that I can provide to help diagnose this issue.


Thank you for your assistance!


I hope this helps! Feel free to modify the text as necessary to fit your specific situation.

@Renaud009
Copy link

Renaud009 commented Jul 22, 2024

Currently trying to fix exactly the same thing. I think a few overrides/modifications are needed in the generated android source files in order to succeed enabling multiple origins in a TWA. More infos about this here https://stackoverflow.com/a/62591136

Those google repos are helpful as well:

I couldn't make it work yet, since I kinda miss the knowledge on how to edit an android project. I'll come back to you if I manage to make it work.

@Renaud009
Copy link

Renaud009 commented Jul 22, 2024

Ok, I made it work by following the Google doc at https://developer.chrome.com/docs/android/trusted-web-activity/multi-origin

  1. Expose same assetlinks.jsonat both origins
  1. Android app sources file must be available or app must be initialized with bubblewrap command bubblewrap init
  2. Make changes to source code to support multiple origins:
    Edit android/app/src/main/res/values/strings.xml
    - by adding a new asset in origins to be validated
    - by adding new value “additional_trusted_origin” trusted origins
    - One item by supported origin

image

Edit android/app/src/main/AndroidManifest.xml
- by adding ADDITIONAL_TRUSTED_ORIGINS
- by editing activity name from “LauncherActivity” to "com.google.androidbrowserhelper.trusted.LauncherActivity” or else the appliation won't launch at all.

image

  1. Build app manually with bubblewrap bubblewrap build
    1. Make sure to increment the version in both android/twa-manifest.json and android/app/build.gradle
    2. Avoid applying manifest changes to project before building
    3. Provide both Key Store and Key passwords
    4. Upload AAB to Google Play Console (the only way to test navbar AFAIK)
      1. Make sure the version was incremented and same keystore was used when building
      2. Create a release for internal testing
      3. On your phone, make sure to delete Google Play Store cache
      4. Install latest version from Google Play Store (by double checking app version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants