navigator.standalone

2,157 views
Skip to first unread message

Lars Tackmann

unread,
Aug 24, 2012, 1:29:56 PM8/24/12
to mi...@dartlang.org
When making mobile sites with JS I usually use navigator.standalone to do feature detection on iOS devices, i.e.

  if(window.navigator.standalone == null) {
    print("not running in iOS browser");
  } else if (window.navigator.standalone == false) {
    print("using mobile safari");
  } else {
    print("running standalone app on iOS");
  }

what's the Dart way of performing this type of feature detection ?


--
Lars Tackmann

Seth Ladd

unread,
Aug 24, 2012, 1:51:10 PM8/24/12
to mi...@dartlang.org
Sounds like a job for JS interop (which I believe is the way to get at browser APIs that we don't ship an equivalent Dart API)  In the meantime, while JS interop is coming online, can you use postMessage to do this?

Also, is there an argument for putting this into Dart's navigator object?


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 

Lars Tackmann

unread,
Aug 24, 2012, 2:07:01 PM8/24/12
to mi...@dartlang.org
On Fri, Aug 24, 2012 at 7:51 PM, Seth Ladd <seth...@google.com> wrote:
> Sounds like a job for JS interop (which I believe is the way to get at
> browser APIs that we don't ship an equivalent Dart API) In the meantime,
> while JS interop is coming online, can you use postMessage to do this?

postMessage is indeed how we are doing it, was just unsure if
something fancier had come along

>
> Also, is there an argument for putting this into Dart's navigator object?

navigator.standalone is iOS specific however when developing mobile
web apps you in general have to style WebView apps differently than
browser based apps (same goes for Android). As the browser app will
have stuff you need to remove (like a topbar) in order to make it
behave like an actual app. WebView (PhoneGap) based apps does not have
this problem. So one could argue that there is some sort of general
concept here that might warent inclusion in Dart.


>
>
> On Fri, Aug 24, 2012 at 1:29 PM, Lars Tackmann <la...@randompage.org> wrote:
>>
>> When making mobile sites with JS I usually use navigator.standalone to do
>> feature detection on iOS devices, i.e.
>>
>> if(window.navigator.standalone == null) {
>> print("not running in iOS browser");
>> } else if (window.navigator.standalone == false) {
>> print("using mobile safari");
>> } else {
>> print("running standalone app on iOS");
>> }
>>
>> what's the Dart way of performing this type of feature detection ?
>>
>>
>> --
>> Lars Tackmann
>>
>> --
>> Consider asking HOWTO questions at Stack Overflow:
>> http://stackoverflow.com/tags/dart
>>
>>
>
>
> --
> Consider asking HOWTO questions at Stack Overflow:
> http://stackoverflow.com/tags/dart
>
>



--
Yours sincerely

Lars Tackmann

John Messerly

unread,
Aug 24, 2012, 2:25:32 PM8/24/12
to mi...@dartlang.org
On Fri, Aug 24, 2012 at 11:07 AM, Lars Tackmann <la...@randompage.org> wrote:
On Fri, Aug 24, 2012 at 7:51 PM, Seth Ladd <seth...@google.com> wrote:
> Sounds like a job for JS interop (which I believe is the way to get at
> browser APIs that we don't ship an equivalent Dart API)  In the meantime,
> while JS interop is coming online, can you use postMessage to do this?

postMessage is indeed how we are doing it, was just unsure if
something fancier had come along

>
> Also, is there an argument for putting this into Dart's navigator object?

navigator.standalone is iOS specific however when developing mobile
web apps you in general have to style WebView apps differently than
browser based apps (same goes for Android). As the browser app will
have stuff you need to remove (like a topbar) in order to make it
behave like an actual app. WebView (PhoneGap) based apps does not have
this problem. So one could argue that there is some sort of general
concept here that might warent inclusion in Dart.

If we wanted to support UIWebView well, are there any other JS APIs we would want to create Dart wrappers for?
How has your experience been using Dart in UIWebView?

Lars Tackmann

unread,
Aug 24, 2012, 2:33:23 PM8/24/12
to mi...@dartlang.org
On Fri, Aug 24, 2012 at 8:25 PM, John Messerly <jmes...@google.com> wrote:
>
> If we wanted to support UIWebView well, are there any other JS APIs we would
> want to create Dart wrappers for?
> How has your experience been using Dart in UIWebView?
>

There are allot although I have not kept count as we will launch
www.solvr.io on the web before (around Dart M1) before we do it on
Android.

The experience with Dart on iOS/Android with UiWebView has been good
(as long as you use latest OS'es for both and strictly use the latest
edition of PhoneGap). I have some code we can share with you if you
want to peek at a large (unfinished) Android app ;) (talk to Seth
about getting access).

Lars Tackmann

unread,
Aug 24, 2012, 2:49:34 PM8/24/12
to mi...@dartlang.org
On Fri, Aug 24, 2012 at 8:33 PM, Lars Tackmann <la...@randompage.org> wrote:
> On Fri, Aug 24, 2012 at 8:25 PM, John Messerly <jmes...@google.com> wrote:
>>
>> If we wanted to support UIWebView well, are there any other JS APIs we would
>> want to create Dart wrappers for?
>> How has your experience been using Dart in UIWebView?
>>
>
> There are allot although I have not kept count as we will launch
> www.solvr.io on the web before (around Dart M1) before we do it on
> Android.

I will try to make a list of the stuff we use and get back to you with it.
Reply all
Reply to author
Forward
0 new messages