You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Ian Clelland <ic...@chromium.org> on 2013/09/06 21:46:06 UTC

Adding cordova.platform property

I brought this up on another thread, but I can't find any reference to the
issue in JIRA, so I'm starting a new thread for visibility.

Since cordova-plugin-device was removed from core, and is now an optional
plugin, there is no easy way to determine at runtime what platform an app
is running on. (And yes, feature detection is usually better than
user-agent detection, but there are legitimate reasons for switching on the
*cordova* platform as opposed to any particular feature available in the
webview)

I'd like to make this property available as `cordova.platform; it would be
a simple string taken from the 'id' defined in
cordova-js/lib/<platform>/platform.js.

Are there any objections to attaching this to the cordova namespace?

Ian

Re: Adding cordova.platform property

Posted by Ian Clelland <ic...@google.com>.
On Friday, September 6, 2013, Jesse wrote:

> +1
> I would expect the return values to be the same platform ids used by
> cordova-cli.[1]


Yes, I believe this is going to be the case. I think it's important that it
return the name of the Cordova platform in use, even if that is totally
disconnected from the actual device that is running the code.


> This would only be a high level value, and if you wanted to know if it was
> iPhone or iPad, you would still need to do additional work, but that to me
> makes sense as feature detection.


Right. If you need to know things about the device itself, then UA
detection, feature detection, or even the device plugin are appropriate.


>
>
> On Fri, Sep 6, 2013 at 1:32 PM, Simon MacDonald
> <simon.macdonald@gmail.com <javascript:;>>wrote:
>
> > +1 I think it is a great idea just don't take it out of device until
> > we sit on it for 6 months and forget to tell people we are removing
> > it. Not that we'd ever do that.
> > Simon Mac Donald
> > http://hi.im/simonmacdonald
> >
> >
> > On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <iclelland@chromium.org<javascript:;>
> >
> > wrote:
> > > I brought this up on another thread, but I can't find any reference to
> > the
> > > issue in JIRA, so I'm starting a new thread for visibility.
> > >
> > > Since cordova-plugin-device was removed from core, and is now an
> optional
> > > plugin, there is no easy way to determine at runtime what platform an
> app
> > > is running on. (And yes, feature detection is usually better than
> > > user-agent detection, but there are legitimate reasons for switching on
> > the
> > > *cordova* platform as opposed to any particular feature available in
> the
> > > webview)
> > >
> > > I'd like to make this property available as `cordova.platform; it would
> > be
> > > a simple string taken from the 'id' defined in
> > > cordova-js/lib/<platform>/platform.js.
> > >
> > > Are there any objections to attaching this to the cordova namespace?
> > >
> > > Ian
> >
>

Re: Adding cordova.platform property

Posted by Jesse <pu...@gmail.com>.
+1
I would expect the return values to be the same platform ids used by
cordova-cli.[1]
This would only be a high level value, and if you wanted to know if it was
iPhone or iPad, you would still need to do additional work, but that to me
makes sense as feature detection.

[1] https://github.com/apache/cordova-cli/blob/master/platforms.js



@purplecabbage
risingj.com


On Fri, Sep 6, 2013 at 1:32 PM, Simon MacDonald
<si...@gmail.com>wrote:

> +1 I think it is a great idea just don't take it out of device until
> we sit on it for 6 months and forget to tell people we are removing
> it. Not that we'd ever do that.
> Simon Mac Donald
> http://hi.im/simonmacdonald
>
>
> On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <ic...@chromium.org>
> wrote:
> > I brought this up on another thread, but I can't find any reference to
> the
> > issue in JIRA, so I'm starting a new thread for visibility.
> >
> > Since cordova-plugin-device was removed from core, and is now an optional
> > plugin, there is no easy way to determine at runtime what platform an app
> > is running on. (And yes, feature detection is usually better than
> > user-agent detection, but there are legitimate reasons for switching on
> the
> > *cordova* platform as opposed to any particular feature available in the
> > webview)
> >
> > I'd like to make this property available as `cordova.platform; it would
> be
> > a simple string taken from the 'id' defined in
> > cordova-js/lib/<platform>/platform.js.
> >
> > Are there any objections to attaching this to the cordova namespace?
> >
> > Ian
>

Re: Adding cordova.platform property

Posted by Simon MacDonald <si...@gmail.com>.
+1 I think it is a great idea just don't take it out of device until
we sit on it for 6 months and forget to tell people we are removing
it. Not that we'd ever do that.
Simon Mac Donald
http://hi.im/simonmacdonald


On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <ic...@chromium.org> wrote:
> I brought this up on another thread, but I can't find any reference to the
> issue in JIRA, so I'm starting a new thread for visibility.
>
> Since cordova-plugin-device was removed from core, and is now an optional
> plugin, there is no easy way to determine at runtime what platform an app
> is running on. (And yes, feature detection is usually better than
> user-agent detection, but there are legitimate reasons for switching on the
> *cordova* platform as opposed to any particular feature available in the
> webview)
>
> I'd like to make this property available as `cordova.platform; it would be
> a simple string taken from the 'id' defined in
> cordova-js/lib/<platform>/platform.js.
>
> Are there any objections to attaching this to the cordova namespace?
>
> Ian

Re: Adding cordova.platform property

Posted by Ian Clelland <ic...@chromium.org>.
Added CB-4761 to track this.


On Sat, Sep 7, 2013 at 6:08 PM, Ian Clelland <ic...@chromium.org> wrote:

>
>
> On Friday, September 6, 2013, Brian LeRoux wrote:
>
>> what does that string return? ios|android|etc? or... ios-7|android-2.3 ???
>>
>> or browser?
>
>
> ios|android|etc
>
> It should be the same platform that cli references. So iOS is iOS, android
> is android,  and windows phone is either wp7 or wp8, depending on the
> platform in use.
>
> If iOS 7 introduces so many incompatibilities that we have to produce a
> new repo anda new cli platform, then on that platform it would return
> "ios7". Ditto for android 4.4 if it were to do the same thing.
>
> Ian
>
>
>>
>>
>> On Fri, Sep 6, 2013 at 1:12 PM, Andrew Grieve <ag...@chromium.org>
>> wrote:
>>
>> > +1 Maybe "cordova.platformId" though
>> >
>> >
>> > On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <ic...@chromium.org>
>> > wrote:
>> >
>> > > I brought this up on another thread, but I can't find any reference to
>> > the
>> > > issue in JIRA, so I'm starting a new thread for visibility.
>> > >
>> > > Since cordova-plugin-device was removed from core, and is now an
>> optional
>> > > plugin, there is no easy way to determine at runtime what platform an
>> app
>> > > is running on. (And yes, feature detection is usually better than
>> > > user-agent detection, but there are legitimate reasons for switching
>> on
>> > the
>> > > *cordova* platform as opposed to any particular feature available in
>> the
>> > > webview)
>> > >
>> > > I'd like to make this property available as `cordova.platform; it
>> would
>> > be
>> > > a simple string taken from the 'id' defined in
>> > > cordova-js/lib/<platform>/platform.js.
>> > >
>> > > Are there any objections to attaching this to the cordova namespace?
>> > >
>> > > Ian
>> > >
>> >
>>
>

Re: Adding cordova.platform property

Posted by Ian Clelland <ic...@chromium.org>.
On Friday, September 6, 2013, Brian LeRoux wrote:

> what does that string return? ios|android|etc? or... ios-7|android-2.3 ???
>
> or browser?


ios|android|etc

It should be the same platform that cli references. So iOS is iOS, android
is android,  and windows phone is either wp7 or wp8, depending on the
platform in use.

If iOS 7 introduces so many incompatibilities that we have to produce a new
repo anda new cli platform, then on that platform it would return "ios7".
Ditto for android 4.4 if it were to do the same thing.

Ian


>
>
> On Fri, Sep 6, 2013 at 1:12 PM, Andrew Grieve <agrieve@chromium.org<javascript:;>>
> wrote:
>
> > +1 Maybe "cordova.platformId" though
> >
> >
> > On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <iclelland@chromium.org<javascript:;>
> >
> > wrote:
> >
> > > I brought this up on another thread, but I can't find any reference to
> > the
> > > issue in JIRA, so I'm starting a new thread for visibility.
> > >
> > > Since cordova-plugin-device was removed from core, and is now an
> optional
> > > plugin, there is no easy way to determine at runtime what platform an
> app
> > > is running on. (And yes, feature detection is usually better than
> > > user-agent detection, but there are legitimate reasons for switching on
> > the
> > > *cordova* platform as opposed to any particular feature available in
> the
> > > webview)
> > >
> > > I'd like to make this property available as `cordova.platform; it would
> > be
> > > a simple string taken from the 'id' defined in
> > > cordova-js/lib/<platform>/platform.js.
> > >
> > > Are there any objections to attaching this to the cordova namespace?
> > >
> > > Ian
> > >
> >
>

Re: Adding cordova.platform property

Posted by Brian LeRoux <b...@brian.io>.
what does that string return? ios|android|etc? or... ios-7|android-2.3 ???

or browser?


On Fri, Sep 6, 2013 at 1:12 PM, Andrew Grieve <ag...@chromium.org> wrote:

> +1 Maybe "cordova.platformId" though
>
>
> On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <ic...@chromium.org>
> wrote:
>
> > I brought this up on another thread, but I can't find any reference to
> the
> > issue in JIRA, so I'm starting a new thread for visibility.
> >
> > Since cordova-plugin-device was removed from core, and is now an optional
> > plugin, there is no easy way to determine at runtime what platform an app
> > is running on. (And yes, feature detection is usually better than
> > user-agent detection, but there are legitimate reasons for switching on
> the
> > *cordova* platform as opposed to any particular feature available in the
> > webview)
> >
> > I'd like to make this property available as `cordova.platform; it would
> be
> > a simple string taken from the 'id' defined in
> > cordova-js/lib/<platform>/platform.js.
> >
> > Are there any objections to attaching this to the cordova namespace?
> >
> > Ian
> >
>

Re: Adding cordova.platform property

Posted by Andrew Grieve <ag...@chromium.org>.
+1 Maybe "cordova.platformId" though


On Fri, Sep 6, 2013 at 3:46 PM, Ian Clelland <ic...@chromium.org> wrote:

> I brought this up on another thread, but I can't find any reference to the
> issue in JIRA, so I'm starting a new thread for visibility.
>
> Since cordova-plugin-device was removed from core, and is now an optional
> plugin, there is no easy way to determine at runtime what platform an app
> is running on. (And yes, feature detection is usually better than
> user-agent detection, but there are legitimate reasons for switching on the
> *cordova* platform as opposed to any particular feature available in the
> webview)
>
> I'd like to make this property available as `cordova.platform; it would be
> a simple string taken from the 'id' defined in
> cordova-js/lib/<platform>/platform.js.
>
> Are there any objections to attaching this to the cordova namespace?
>
> Ian
>