Great thank you, works a treat :)

On Monday, August 17, 2020 at 9:53:28 AM UTC+12 [email protected] wrote:

>
>
> On Sunday, August 16, 2020 at 11:41:18 PM UTC+2, Michael Harray wrote:
>>
>> Hello, I'm currently working on PWA functionality in our GWT app, trying 
>> to utilise Elemental2 / JSInterop where possible instead of writing 
>> javascript. To detect if the app is launched in PWA mode on IOS, this is 
>> the recommended javascript:
>>
>>
>> const isInStandaloneMode = () => ('standalone' in window.navigator) && 
>> (window.navigator.standalone);  
>>
>> However there appears to be no DomGlobal.window.navigator.standalone 
>> object in Elemental2, as I'm guessing it has not been standardised. 
>>
>> So my question is, is there a recommended way to define this object so 
>> that I can replicate the above javascript without resorting to JSNI? Or is 
>> there another way to achieve this?
>>
>
> I would simply use jsinterop-base' JsPropertyMap: 
> https://javadoc.io/doc/com.google.jsinterop/base/latest/jsinterop/base/JsPropertyMap.html
> Something like:
>
> public static boolean isInStandaloneMode() {
>   var navigator = Js.asPropertyMap(DomGlobale.window.navigator);
>   return navigator.has("standalone") && Js.isTruthy(navigator.get(
> "standalone"));
> }
>
> The navigator.get("standalone") translates to navigator["standalone"] 
> rather than navigator.standalone, but that should be strictly equivalent 
> (navigator is a browser object, so you're never really sure, but IIRC 
> things were only "strange" in IE). You could use JsInterop for that part if 
> needed.
>
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/418d0be7-48de-46eb-b43d-62497a8dbdd1n%40googlegroups.com.

Reply via email to