GithubHelp home page GithubHelp logo

rikudousage / pwatotwa Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 8.0 66 KB

Convert your PWA to an Android application using Trusted Web Activities (TWA)

License: MIT License

C++ 93.65% QMake 4.75% Shell 1.60%
pwa twa apk

pwatotwa's Introduction

Convert PWA to Android APK / TWA

This tool creates an Android Studio project from your Progressive Web Application (PWA).

The usage is fairly simple, it uses official Google example as a base and replaces values and images fetched from your PWA site.

After running this tool you should be able to open the newly created project in Android Studio and make any modifications you want.

Note that this tool is in a really early state and thus may fail anytime. I tested it with Angular powered apps and it worked well but results with other frameworks may vary. If it doesn't work for you, create an issue.

The PWA needs to specify that your app can access the content, read more here

Installation

You can either download the compiled static binary from releases or compile it yourself.

Usage

This tool takes three parameters:

  1. The android package name (e.g. com.example.my_pwa)
  2. The PWA url (e.g. https://my_pwa.example.com)
  3. The output directory (e.g. ./my-cool-pwa)

If the manifest path is not in html source code or could not be detected for any other reason, you can add the relative path to your manifest using the --manifest option (relative to the PWA url).

You can even have the manifest in a local file and use it instead of fetching it from the web using the --local-manifest option.

Example:

pwa-to-twa com.example.my_pwa https://my_pwa.example.com ./my-cool-pwa

Example with --manifest option:

pwa-to-twa com.example.my_pwa https://my_pwa.example.com ./my-cool-pwa --manifest /manifest.json

Example with --local-manifest:

pwa-to-twa com.example.my_pwa https://my_pwa.example.com ./my-cool-pwa --local-manifest ./manifest.json

Dependencies

This tool needs these cli tools to be able to work:

  • convert (from ImageMagick)

Building from source

You need the Qt framework (tested with 5.10.1) and libgit2 (on Ubuntu you can use apt install libgit2-dev).

Change into the cloned directory and:

  • git submodule init
  • git submodule update
  • qmake pwa-to-twa.pro
  • make

The binary file pwa-to-twa will be created, to test that everything works run ./pwa-to-twa, you should see something like this:

Usage: ./pwa-to-twa androidPackageName pwaUrl outputPath [--manifest path-to-manifest] [--local-manifest path-to-manifest]
Example: ./pwa-to-twa com.vendor.pwa https://pwa.vendor.com ./my-cool-pwa
Example: ./pwa-to-twa com.vendor.pwa https://pwa.vendor.com ./my-cool-pwa --manifest relative/path/to/manifest
Example: ./pwa-to-twa com.vendor.pwa https://pwa.vendor.com ./my-cool-pwa --local-manifest ./manifest.json

Building statically

You need to have docker installed.

Change into the cloned directory and:

  • ./configure-static
  • ./build-static

This command will download the necessary image and statically compile the app to binary file pwa-to-twa. (Binary created using the same command is always available in releases).

pwatotwa's People

Contributors

rikudousage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pwatotwa's Issues

Can't make it work using --manifest option

Hi there,
I have my PWA working fine on my domain, but manifest file is only accessible directly after login, so I downloaded the manifest file locally and tried your tool with --manifest option, but it always tries to access the remote manifest file.
./pwa-to-twa_0.0.11_18.04_bionic com.test.jotwa https://test.com/Todo_crud ./jotwa --manifest ./manifest.json The manifest at url 'https://test.com/Todo_crud/./manifest.json' is missing these keys: short_name, theme_color, background_color, start_url
Indeed, since it's not logged in from the CLI, manifest reroute to a login page.
The local manifest.json file is:
{
"short_name": "PWA",
"name": "PWA",
"icons": [
{
"src": "/images/logo_512x512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/index",
"background_color": "#FFFFFF",
"display": "standalone",
"scope": "/",
"theme_color": "#3F51B5"
}
About --manifest, I tried all possible combinations I think ๐Ÿ˜„
Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.