Launch PWA Add To Home Screen from another app on Android/iOS

Viewed 262

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!

1 Answers

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

Related