3

I have a somewhat weird question where I don't actually know the correct terminology so if I incorrectly state something please correct me so I can better ask this question. Right now I guess I'm more focused on Android since I have one and can easily emulate and test, but eventually I would like to get it to work on iOS.

Goal: Launch a PWA (Progressive Web App) which was added to the home screen of my device through the A2HS (Add To Home Screen) from another application.

So I currently have two PWA added to my home screen through google chrome, called PWA1 and PWA2. These are URLs that when accessed VIA chrome I can add to my home page through A2HS and when I open it, it functions and looks just like an app.

  • MyApp - Android/iOS app Xamarin
  • PWA1/2 - Progressive Web App added to home screen using Google Chrome's A2HS

I am currently working on another app right now called MyApp, and I would like to know how I can launch my PWA1 and PWA2 from within MyApp. I know I am able to launch other apps installed on my device using PackageManager and intent to launch the app but since these aren't actually real apps I have no idea how to access the ones that are saved to my home screen.

I'm pretty sure I can implement the button on my app opening com.android.chrome but that would just open the chrome app not specifically the PWA on my home screen. So how would I go about doing this?

My first train of thought is that somewhere on the Android OS or in Chrome there is a lookup of the available PWA added to the home screen. If I am able to find that I was hoping there was a way to specify to chrome or the PackageManager that I want to launch com.android.chrome:PWA1 and it will load the one that was added to my home screen.

Any feed back on whether this is possible, or what I should clarify would be greatly appreciated!

97WaterPolo
  • 375
  • 1
  • 3
  • 24
  • Possibly related: https://developers.google.com/web/fundamentals/integration/webapks – Morrison Chang Feb 11 '22 at 23:52
  • Interesting so one of my applications PWA1 is a WebAPK where it is installed on the phone and searchable in the app drawer and PWA2 is just the A2HS from chrome, shows up on the home screen but not in my app drawer. – 97WaterPolo Feb 12 '22 at 00:14

1 Answers1

2

I have triggered the prompt to choose to open the link from PWA or the browser.

I'm using Custom Tab from Chrome, you can read implementation here.

Something like this:

CustomTabsIntent.Builder().apply {
        setShowTitle(true)
        setUrlBarHidingEnabled(true)
        setColorScheme(COLOR_SCHEME_SYSTEM)
        setInstantAppsEnabled(false)
        setStartAnimations(this@openWeb, R.anim.right_in, R.anim.left_out)
        setExitAnimations(this@openWeb, R.anim.left_in, R.anim.right_out)
        setShareState(SHARE_STATE_OFF)
    }.build().launchUrl(this, Uri.parse("https://your.pwa.url"))

If you installed the PWA in your device, when opening the link using the custom tab... it should triggered the prompt, like this:

Prompt

Or if you choose your PWA as default app to handle your link, it should automatically open your PWA

Jimly Asshiddiqy
  • 335
  • 4
  • 15
  • Do you happen to have any code examples of how you would actually launch the it in the PWA? Are you saying that if you hit the URL it will then prompt to open in the custom tabs browser OR the Install PWA, and once the popup appears you can set it to the PWA installed on the phone? – 97WaterPolo Feb 16 '22 at 18:07
  • I've edited the answer, please flag this answer accepted if it helps. Thanks :) – Jimly Asshiddiqy Feb 17 '22 at 02:21