简体   繁体   中英

Suppress PWA installation on iOS, only add shortcut to Home Screen

I have a PWA that works fine on Android, but is crippled on iOS due to limitations opposed on PWAs imposed by iOS (specifically accessing live camera frames). The app works fine when viewed in Safari. This is counter-intuitive but unfortunately the case.

Is there a way to tell iOS that it should not "install" the PWA, but instead just create a shortcut on the home screen and open it in regular Safari? Like any ol' website?

Or do I need a specific index.html for iOS that does not include the manifest.json reference? The PWA is a single-page Angular application.

Answering my own question. I managed to solve this by programmatically removing the manifest element in the OnInit hook of the AppComponent.

In index.html:

<link rel="manifest" href="manifest.json" id="manifest-link">

In the AppComponent:

ngOnInit() {

   // ... platform detection
   if (isiOS) {
       const element = document.getElementById('manifest-link');
       console.log(`Removing manifest element on iOS, should suppress PWA installation`);
       element.remove();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM