Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38594
| Subject | Re: Set desktop PWA size |
|---|---|
| Newsgroups | comp.lang.javascript |
| References | <o4udnZa8gdNhgofCnZ2dnUU7-b_NnZ2d@westnet.com.au> <64ec8085-534d-4774-863c-b9fbb5ab1f68o@googlegroups.com> |
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Date | 2020-07-24 18:06 +1000 |
| Message-ID | <EbOdnTYgueUaC4fCnZ2dnUU7-X3NnZ2d@westnet.com.au> (permalink) |
On 24/07/2020 3:38 pm, Michael Haufe (TNO) wrote:
> On Thursday, July 23, 2020 at 6:40:53 PM UTC-5, Andrew Poulos wrote:
>> I have a website that can be installed as a desktop PWA. While the app
>> is responsive it looks "better" if the window is proportioned as
>> landscape. So is there a way to set the window size when they app is
>> launched without requiring user interaction?
>>
>> I understand why user interaction is usually required but as a user
>> chooses to install it as a PWA would it be more trusted?
>>
>
> Yes. I did this for the app at my recent startup company. It looked something like this:
>
> ```
> class Application {
> ...
> async load() {
> ...
> await this.installOrUpdateServiceWorker();
> ...
> let browserUtil = new BrowserUtil();
>
> if(browserUtil.isStandaloneMode()) {
> browserUtil.resizeWindow();
> }
> }
> ...
> }
> ```
>
> ```
> class BrowserUtil {
> ...
> /**
> * If installed to homescreen on desktop or tablet, resize the window to mobile size
> */
> resizeWindow() {
> const HAND_HELD_MAX_WIDTH = 414;
> const HAND_HELD_MAX_HEIGHT = 812;
> resizeTo(
> Math.min(screen.availWidth, HAND_HELD_MAX_WIDTH),
> Math.min(screen.availHeight, HAND_HELD_MAX_HEIGHT)
> );
> }
> isStandaloneMode(): boolean {
> return this.isIphone() ?
> ('standalone' in window.navigator) && (window.navigator as any).standalone :
> window.matchMedia('(display-mode: standalone)').matches;
> }
> /**
> * Determines if the current browser has the standard Add To HomeScreen support
> */
> supportsInstallPromptEvent(): boolean {
> return window.hasOwnProperty('onbeforeinstallprompt');
> }
> ...
> }
> ```
>
> In regards to trust: You have to have SSL to prompt install in the first place. The fact that the user chose to install it is a strong sign of trust from the user.
Thanks. I've got it working...
Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Set desktop PWA size Andrew Poulos <ap_prog@hotmail.com> - 2020-07-24 09:40 +1000
Re: Set desktop PWA size "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-07-23 22:38 -0700
Re: Set desktop PWA size Andrew Poulos <ap_prog@hotmail.com> - 2020-07-24 18:06 +1000
csiph-web