Open Source & Free  

Install on Home Screen

Install on Home Screen

Header Image

We talked about our support for Progressive Web Apps before. We added quite a few enhancements since that support was introduced and it’s a pretty powerful feature. Personally I consider it a killer feature, even if Google decides to ban your account you can still distribute your app.

One of the cool features is the seamlessness. Most of the functionality “just works”. However, there are some cases where we need explicit hints due to the different behavior of desktop/mobile and web.

One such case is installation. PWA’s support an icon on the device home screen, but you need to explicitly ask the browser to install that icon. That’s unique to PWA’s and requires a new API to support that behavior. That’s why we introduced onCanInstallOnHomescreen, canInstallOnHomescreen() and promptInstallOnHomescreen() to help with that process. You can use them as:

    if (canInstallOnHomescreen()) {
        if (promptInstallOnHomescreen()) {
            // User accepted installation
        } else {
            // user rejected installation
This code expects import static com.codename1.ui.CN.*;

The code would prompt the user to install on the home screen in OS’s where this is appropriate. Notice that this will prompt the user once to install on the home screen so you don’t need additional guards against duplicate prompts.

Leave a Reply