Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 5b4c699

Browse files
committed
Writing new post 🚀
1 parent 255a4fb commit 5b4c699

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

_drafts/2019-06-15-google-play-store-publish-pwa.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,70 @@ Let's start to see the real action: how I publish my blog PWA to the Google Play
3838

3939
{% include blog-lazy-image.html description="pwa app create project" src="/assets/images/posts/pwa-app-01-create-project.png" %}
4040

41-
Then I added the TWA support as a dependecy of the app. The TWA implementation is contained inside the custom tabs client library published on jitpack (because unfortunately at the moment of this writing the custom tabs client library contained inside Jetpack doesn't have the TWA support). So I added jitpack as repository to the project level gradle file and the I added the custom tabs client library as dependecy inside the module gradle file. This dependecies points to the custom tabs client library published on github and exposed through Jitpack. I had also to specify a specific commit hash in order to be sure that the library version downloaded has dependecies contains the TWA support.
41+
Then I added the TWA support as a dependecy of the app. The TWA implementation is contained inside the custom tabs client library published on [Jitpack](https://jitpack.io/ "Jitpack") (because unfortunately at the moment of this writing the custom tabs client library contained inside Jetpack doesn't have the TWA support). So I added Jitpack as repository to the project level gradle file. Then I added the custom tabs client library as dependecy inside the module gradle file. This last dependecy points to the custom tabs client library published on github and exposed through Jitpack. I had also to specify a specific commit hash in order to be sure that the library version downloaded contains the TWA support.
4242

4343
{% include blog-lazy-image.html description="pwa app jitpack" src="/assets/images/posts/pwa-app-02-jitpack-configuration.png" %}
4444
{% include blog-lazy-image.html description="pwa app custom tab library" src="/assets/images/posts/pwa-app-03-java8-and-custom-tab-dependecies.png" %}
4545

46-
...
46+
After the depencies setup I added the TWA Activity. To do this I just had to modify the Android app manifest file by declaring a new TWA activity inside it. For the readers that are not mobile developer, the Android app manifest is a file contained in all the Android apps. Its main function is to present essential information about the application to the Android system including:
47+
48+
* the Java package of the app
49+
* the components of the app including activities, services, broadcast receivers, and content providers that the app is composed of
50+
* which permissions the app must have in order to access protected parts of the API
51+
52+
The declaration of the TWA inside the Android app manifest must include some important information:
53+
54+
* a `meta-data` tag that must contain the url to be opened by the TWA
55+
* an `intent-filter` that adds the TWA to the Android Launcher
56+
* another `intent-filter` that allows the TWA to intercept Android Intents that open https://airhorner.com. The `android:host` attribute inside the data tag must point to the domain being opened by the TWA and specified in the `meta-data` tag.
57+
58+
{% include blog-lazy-image.html description="pwa app twa declaration" src="/assets/images/posts/pwa-app-04-twa-activity-declaration.png" %}
59+
60+
Now I need to establish the link between our PWA website and our PWA app. This is a two way operation because I need to:
61+
62+
* establish an association from app to the website
63+
* establish an association from the website to the app
64+
65+
This associations will remove automatically the url address bar from the TWA activity. In this way the Android app will full screen as a standard one (and as a PWA in standalone mode :smirk:).
66+
Let's start from the first association, from the app to the web site. To do this I created a new string resource inside the `strings.xml` file. This new string resouce contains the Digital AssetLink statement that you can see below.
67+
68+
```xml
69+
<resources>
70+
<string name="app_name">Chicio Coding</string>
71+
<string name="asset_statements">
72+
[{
73+
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
74+
\"target\": {
75+
\"namespace\": \"web\",
76+
\"site\": \"https://www.fabrizioduroni.it\"}
77+
}]
78+
</string>
79+
</resources>
80+
```
81+
82+
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement" src="/assets/images/posts/pwa-app-05-associate-app-to-web-1.png" %}
83+
84+
I can link this string resource statement inside the Android app manifest by adding a new `meta-data` tag as child of the `application` tag (NOT inside the TWA declaration).
85+
86+
{% include blog-lazy-image.html description="pwa app Digital AssetLink statement manifest" src="/assets/images/posts/pwa-app-05-associate-app-to-web-2.png" %}
87+
88+
It is possible to test that the association from app to the website has been completed. To do this I had to:
89+
90+
* open Chrome on the development device, navigate to `chrome://flags`, search for an item called Enable command line on non-rooted devices and change it to ENABLED and then restart the browser.
91+
* on the terminal application of your OS, use the Android Debug Bridge (`adb`) to run the following command:
92+
93+
```shell
94+
adb shell "echo '_ --disable-digital-asset-link-verification-for-url=\"https://www.fabrizioduroni.it\"' > /data/local/tmp/chrome-command-line"
95+
```
96+
97+
After this setup if I run the app from Android Studio the address bar is gone :relieved:.
98+
Now I need to finish the development by establishing an association from the website to the app. ..........
99+
100+
101+
102+
```shell
103+
keytool -list -v -keystore <your keystore jks file> -alias <your alias> -storepass <your store psw> -keypass <your key psw>
104+
```
105+
106+
107+
{% include blog-lazy-image.html description="pwa app Digital AssetLink generator" src="/assets/images/posts/pwa-app-07-assetlink-generator.png" %}
1020 KB
Loading
850 KB
Loading
918 KB
Loading
686 KB
Loading

0 commit comments

Comments
 (0)