You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Filip Maj <fi...@adobe.com> on 2012/12/01 00:27:45 UTC

Determining if "you're in cordova"

I'm seeing this question pop up on our IRC, as well as in person after
meet ups, as well as on stack overflow here and there.

Scenario: I have a website, and I have a native app that uses cordova. My
cordova apps simply point to the website URL to get its contents.

The question becomes: since both browser and native versions of the app
include cordova.js, how do we know if we're in cordova or not?

I'm leaning towards a functional approach to determining that. Basically,
does the bridge work?

I know the easy answer from us is "don't do that" but I think for
platforms that don't have a stringent review process and want to oppress
apps from loading code dynamically (you know who you are) this is a
valuable approach. The build process can solve this problem but I still
think coming up with a good answer to this question has value.

What about during cordova.js' initialization we test the bridge (echo
plugin?). If it works, we set window.cordova.isWebView or some shit. If it
doesn't, well, it deosnt.

Thoughts/comments welcome!


Re: Determining if "you're in cordova"

Posted by Anis KADRI <an...@gmail.com>.
Setting "Cordova" in the UA is not really hard to achieve (at least on
Android). Not sure if we would want to make this default though.

On Fri, Nov 30, 2012 at 3:27 PM, Filip Maj <fi...@adobe.com> wrote:

> My
> cordova apps simply point to the website URL to get its contents.
>

I don't know if this is really a good idea in the first place. What happens
when there is no connectivity ? Why have an app then ?

Re: Determining if "you're in cordova"

Posted by Patrick Mueller <pm...@gmail.com>.
On Fri, Nov 30, 2012 at 6:27 PM, Filip Maj <fi...@adobe.com> wrote:

> The question becomes: since both browser and native versions of the app
> include cordova.js, how do we know if we're in cordova or not?
>

Great question.


> What about during cordova.js' initialization we test the bridge (echo
> plugin?). If it works, we set window.cordova.isWebView or some shit. If it
> doesn't, well, it deosnt.
>

When are you allowed to check for whether window.cordova.isWebView is set?
 Obviously by the time "deviceready" fires, but ... is there some other
event or timeframe?

-- 
Patrick Mueller
http://muellerware.org

Re: Determining if "you're in cordova"

Posted by Anis KADRI <an...@gmail.com>.
On Mon, Dec 3, 2012 at 3:53 PM, Brian LeRoux <b...@brian.io> wrote:

> I'm of the opinion this isn't a Cordova problem----but I do think
> device capabilities introspection is. (Which is related.)
>

+1

There are so many ways to find out.

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
This situation all still smells of userland issue not something
Cordova should be doing.

I do think we need device capability detection, but analytics use case
not strong enough to justify adding to the fragmented world that is
user agents strings (and the even more brittle world of code that
parses them).



On Tue, Dec 4, 2012 at 9:54 AM, Patrick Mueller <pm...@gmail.com> wrote:
> On Mon, Dec 3, 2012 at 8:32 PM, Andrew Lunny <al...@gmail.com> wrote:
>
>> The problem, afaict, is distinguishing between:
>>
>> 1) deviceready hasn't fired yet
>> 2) deviceready isn't ever going to fire
>>
>> which right now boils down to "guess how long deviceready will take, and
>> setTimeout() until some time after that."
>>
>
> Yup.  Exactly.
>
>
>> I tend to agree with Max - it'd be a worthwhile thing to have, unless the
>> implementation is prohibitively difficult.
>>
>
> The implementation of this isn't difficult.  It is however, suspect, since
> it's based on some arbitrary time amount.  Is 5 seconds long enough - seems
> like it would be.  But maybe not.  10?  Do we decide what this number is,
> or does the user?  I can see the questions on the Google group already ...
> :-)
>
> And what is the app supposed to do until this time amount expires?
>
> When I think about the problem like that, I start to think "progressive
> enhancement".  eg, build this page in such a way that it will "work",
> presumably in some degraded way, if deviceready never fires, and then if
> deviceready DOES fire, reshuffle your bits to take that into account.
>
> --
> Patrick Mueller
> http://muellerware.org

Re: Determining if "you're in cordova"

Posted by Patrick Mueller <pm...@gmail.com>.
On Mon, Dec 3, 2012 at 8:32 PM, Andrew Lunny <al...@gmail.com> wrote:

> The problem, afaict, is distinguishing between:
>
> 1) deviceready hasn't fired yet
> 2) deviceready isn't ever going to fire
>
> which right now boils down to "guess how long deviceready will take, and
> setTimeout() until some time after that."
>

Yup.  Exactly.


> I tend to agree with Max - it'd be a worthwhile thing to have, unless the
> implementation is prohibitively difficult.
>

The implementation of this isn't difficult.  It is however, suspect, since
it's based on some arbitrary time amount.  Is 5 seconds long enough - seems
like it would be.  But maybe not.  10?  Do we decide what this number is,
or does the user?  I can see the questions on the Google group already ...
:-)

And what is the app supposed to do until this time amount expires?

When I think about the problem like that, I start to think "progressive
enhancement".  eg, build this page in such a way that it will "work",
presumably in some degraded way, if deviceready never fires, and then if
deviceready DOES fire, reshuffle your bits to take that into account.

-- 
Patrick Mueller
http://muellerware.org

Re: Determining if "you're in cordova"

Posted by Filip Maj <fi...@adobe.com>.
>The primary alternative is maybe to use a build system that adds in the
>platform-specific files when packaging apps, while keeping your source
>tree
>runnable in a browser...

This is the way to go. Take advantage of the compile step to customize
packages/binaries for specific platforms.


Re: Determining if "you're in cordova"

Posted by Brion Vibber <br...@pobox.com>.
On Dec 3, 2012 7:42 PM, "Andrew Grieve" <ag...@chromium.org> wrote:
>
> I don't really understand using cordova.js outside of Cordova. There's one
> for every platform, so which one gets included in the web version?

In the Wikipedia app we have a single codebase for several platforms and
load the appropriate Cordova.js (if any) based on the detected user-agent.
So in a browser, we don't load any Cordova.js.

Basically what I think is needed is a way to check if we *should* load a
Cordova.js, and if so which one.

Currently we take a shortcut and assume anything on Android or iOS is
running in the Cordova app.

The primary alternative is maybe to use a build system that adds in the
platform-specific files when packaging apps, while keeping your source tree
runnable in a browser...

-- brion

Re: Determining if "you're in cordova"

Posted by Andrew Grieve <ag...@chromium.org>.
I don't really understand using cordova.js outside of Cordova. There's one
for every platform, so which one gets included in the web version?

It's a neat idea to have a web-platform that just has things like
cordova/util in it, or that has everything except an exec() implementation
in it... Maybe for unit testing purposes, or to aid projects like Ripple.

I also like the idea of making it easy for apps to append a suffix to the
User-Agent. Good for analytics.


On Mon, Dec 3, 2012 at 8:32 PM, Andrew Lunny <al...@gmail.com> wrote:

> The problem, afaict, is distinguishing between:
>
> 1) deviceready hasn't fired yet
> 2) deviceready isn't ever going to fire
>
> which right now boils down to "guess how long deviceready will take, and
> setTimeout() until some time after that."
>
> I tend to agree with Max - it'd be a worthwhile thing to have, unless the
> implementation is prohibitively difficult.
>
> On 3 December 2012 17:17, Anis KADRI <an...@gmail.com> wrote:
>
> > Well because it never fires you know that you are in a browser's context.
> > It will only fire if you're on a device or if you fire it yourself.
> >
> > There could be two reasons (as far as I know) that 'deviceready' would
> not
> > fire.
> > 1) not in a cordova app context (browser via file:// or http://).
> > 2) there is a problem with cordova itself (problem fetching
> device/network
> > info).
> >
> > actions for both
> > 1) You know whether or not you are in a cordova context: do whatever you
> > have to do: use childbrowser or a popup,  don't use device apis that are
> > not available etc...
> > 2) find out if you're not missing anything and/or file a bug
> >
> > I believe that 'deviceready' is more reliable then document.location
> > because it really is cordova specific.
> >
> >
> >
> >
> > On Mon, Dec 3, 2012 at 5:06 PM, Filip Maj <fi...@adobe.com> wrote:
> >
> > > But look at that situation from the browser's POV: it attaches to an
> > event
> > > that never fires.
> > >
> > > cordova.js is included and window.cordova exists, but in a browser's
> > > context, it does nothing.
> > >
> > > On 12/3/12 5:03 PM, "Anis KADRI" <an...@gmail.com> wrote:
> > >
> > > >document.addEventListener('deviceready', function()
> > {navigator.inCordova =
> > > >true;}, false);
> > > >
> > > >If you fire 'deviceready' yourself then you already know that you're
> not
> > > >in
> > > >a cordova app context. Don't you ?
> > > >
> > > >Sorry, I really don't see what the problem is. Maybe an real world
> > example
> > > >would help illustrate it. Or is there a reason why you don't want to
> use
> > > >deviceready as an indicator ?
> > > >
> > > >
> > > >On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> > > >
> > > >> if cordova polyfilled standard apis for everything it wouldn't be
> > > >>cordovas
> > > >> problem. but right now there are only-in-cordova APIs that I need to
> > > >>use if
> > > >> i'm in cordova. it would be more convenient for me as an app
> developer
> > > >>if
> > > >> there was a supported way to know i'm in cordova.
> > > >>
> > > >> I can keep looking at window.location.href and make sure to always
> > run a
> > > >> local web server for development (and never open the file directly
> on
> > my
> > > >> dev machine) but the point here is that doing those things is more
> > > >>pitfall
> > > >> prone and less user friendly for new devs than doing "if
> > > >> (navigator.inCordova)".
> > > >>
> > > >> if its a ton of work to implement then I can understand not doing it
> > (I
> > > >> dont know what it would take to implement). i'm just trying to say
> it
> > > >>would
> > > >> be a nicer api :) it seems from my perspective that it would be easy
> > for
> > > >> cordova to tell the browser that cordova is present and it would
> save
> > > >>app
> > > >> developers from having to use yet another hacky technique.
> > > >>
> > >
> > >
> >
>

Re: Determining if "you're in cordova"

Posted by Andrew Lunny <al...@gmail.com>.
The problem, afaict, is distinguishing between:

1) deviceready hasn't fired yet
2) deviceready isn't ever going to fire

which right now boils down to "guess how long deviceready will take, and
setTimeout() until some time after that."

I tend to agree with Max - it'd be a worthwhile thing to have, unless the
implementation is prohibitively difficult.

On 3 December 2012 17:17, Anis KADRI <an...@gmail.com> wrote:

> Well because it never fires you know that you are in a browser's context.
> It will only fire if you're on a device or if you fire it yourself.
>
> There could be two reasons (as far as I know) that 'deviceready' would not
> fire.
> 1) not in a cordova app context (browser via file:// or http://).
> 2) there is a problem with cordova itself (problem fetching device/network
> info).
>
> actions for both
> 1) You know whether or not you are in a cordova context: do whatever you
> have to do: use childbrowser or a popup,  don't use device apis that are
> not available etc...
> 2) find out if you're not missing anything and/or file a bug
>
> I believe that 'deviceready' is more reliable then document.location
> because it really is cordova specific.
>
>
>
>
> On Mon, Dec 3, 2012 at 5:06 PM, Filip Maj <fi...@adobe.com> wrote:
>
> > But look at that situation from the browser's POV: it attaches to an
> event
> > that never fires.
> >
> > cordova.js is included and window.cordova exists, but in a browser's
> > context, it does nothing.
> >
> > On 12/3/12 5:03 PM, "Anis KADRI" <an...@gmail.com> wrote:
> >
> > >document.addEventListener('deviceready', function()
> {navigator.inCordova =
> > >true;}, false);
> > >
> > >If you fire 'deviceready' yourself then you already know that you're not
> > >in
> > >a cordova app context. Don't you ?
> > >
> > >Sorry, I really don't see what the problem is. Maybe an real world
> example
> > >would help illustrate it. Or is there a reason why you don't want to use
> > >deviceready as an indicator ?
> > >
> > >
> > >On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> > >
> > >> if cordova polyfilled standard apis for everything it wouldn't be
> > >>cordovas
> > >> problem. but right now there are only-in-cordova APIs that I need to
> > >>use if
> > >> i'm in cordova. it would be more convenient for me as an app developer
> > >>if
> > >> there was a supported way to know i'm in cordova.
> > >>
> > >> I can keep looking at window.location.href and make sure to always
> run a
> > >> local web server for development (and never open the file directly on
> my
> > >> dev machine) but the point here is that doing those things is more
> > >>pitfall
> > >> prone and less user friendly for new devs than doing "if
> > >> (navigator.inCordova)".
> > >>
> > >> if its a ton of work to implement then I can understand not doing it
> (I
> > >> dont know what it would take to implement). i'm just trying to say it
> > >>would
> > >> be a nicer api :) it seems from my perspective that it would be easy
> for
> > >> cordova to tell the browser that cordova is present and it would save
> > >>app
> > >> developers from having to use yet another hacky technique.
> > >>
> >
> >
>

Re: Determining if "you're in cordova"

Posted by Anis KADRI <an...@gmail.com>.
Well because it never fires you know that you are in a browser's context.
It will only fire if you're on a device or if you fire it yourself.

There could be two reasons (as far as I know) that 'deviceready' would not
fire.
1) not in a cordova app context (browser via file:// or http://).
2) there is a problem with cordova itself (problem fetching device/network
info).

actions for both
1) You know whether or not you are in a cordova context: do whatever you
have to do: use childbrowser or a popup,  don't use device apis that are
not available etc...
2) find out if you're not missing anything and/or file a bug

I believe that 'deviceready' is more reliable then document.location
because it really is cordova specific.




On Mon, Dec 3, 2012 at 5:06 PM, Filip Maj <fi...@adobe.com> wrote:

> But look at that situation from the browser's POV: it attaches to an event
> that never fires.
>
> cordova.js is included and window.cordova exists, but in a browser's
> context, it does nothing.
>
> On 12/3/12 5:03 PM, "Anis KADRI" <an...@gmail.com> wrote:
>
> >document.addEventListener('deviceready', function() {navigator.inCordova =
> >true;}, false);
> >
> >If you fire 'deviceready' yourself then you already know that you're not
> >in
> >a cordova app context. Don't you ?
> >
> >Sorry, I really don't see what the problem is. Maybe an real world example
> >would help illustrate it. Or is there a reason why you don't want to use
> >deviceready as an indicator ?
> >
> >
> >On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> >
> >> if cordova polyfilled standard apis for everything it wouldn't be
> >>cordovas
> >> problem. but right now there are only-in-cordova APIs that I need to
> >>use if
> >> i'm in cordova. it would be more convenient for me as an app developer
> >>if
> >> there was a supported way to know i'm in cordova.
> >>
> >> I can keep looking at window.location.href and make sure to always run a
> >> local web server for development (and never open the file directly on my
> >> dev machine) but the point here is that doing those things is more
> >>pitfall
> >> prone and less user friendly for new devs than doing "if
> >> (navigator.inCordova)".
> >>
> >> if its a ton of work to implement then I can understand not doing it (I
> >> dont know what it would take to implement). i'm just trying to say it
> >>would
> >> be a nicer api :) it seems from my perspective that it would be easy for
> >> cordova to tell the browser that cordova is present and it would save
> >>app
> >> developers from having to use yet another hacky technique.
> >>
>
>

Re: Determining if "you're in cordova"

Posted by Filip Maj <fi...@adobe.com>.
But look at that situation from the browser's POV: it attaches to an event
that never fires. 

cordova.js is included and window.cordova exists, but in a browser's
context, it does nothing.

On 12/3/12 5:03 PM, "Anis KADRI" <an...@gmail.com> wrote:

>document.addEventListener('deviceready', function() {navigator.inCordova =
>true;}, false);
>
>If you fire 'deviceready' yourself then you already know that you're not
>in
>a cordova app context. Don't you ?
>
>Sorry, I really don't see what the problem is. Maybe an real world example
>would help illustrate it. Or is there a reason why you don't want to use
>deviceready as an indicator ?
>
>
>On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>
>> if cordova polyfilled standard apis for everything it wouldn't be
>>cordovas
>> problem. but right now there are only-in-cordova APIs that I need to
>>use if
>> i'm in cordova. it would be more convenient for me as an app developer
>>if
>> there was a supported way to know i'm in cordova.
>>
>> I can keep looking at window.location.href and make sure to always run a
>> local web server for development (and never open the file directly on my
>> dev machine) but the point here is that doing those things is more
>>pitfall
>> prone and less user friendly for new devs than doing "if
>> (navigator.inCordova)".
>>
>> if its a ton of work to implement then I can understand not doing it (I
>> dont know what it would take to implement). i'm just trying to say it
>>would
>> be a nicer api :) it seems from my perspective that it would be easy for
>> cordova to tell the browser that cordova is present and it would save
>>app
>> developers from having to use yet another hacky technique.
>>


Re: Determining if "you're in cordova"

Posted by Anis KADRI <an...@gmail.com>.
document.addEventListener('deviceready', function() {navigator.inCordova =
true;}, false);

If you fire 'deviceready' yourself then you already know that you're not in
a cordova app context. Don't you ?

Sorry, I really don't see what the problem is. Maybe an real world example
would help illustrate it. Or is there a reason why you don't want to use
deviceready as an indicator ?


On Mon, Dec 3, 2012 at 4:40 PM, Max Ogden <ma...@maxogden.com> wrote:

> if cordova polyfilled standard apis for everything it wouldn't be cordovas
> problem. but right now there are only-in-cordova APIs that I need to use if
> i'm in cordova. it would be more convenient for me as an app developer if
> there was a supported way to know i'm in cordova.
>
> I can keep looking at window.location.href and make sure to always run a
> local web server for development (and never open the file directly on my
> dev machine) but the point here is that doing those things is more pitfall
> prone and less user friendly for new devs than doing "if
> (navigator.inCordova)".
>
> if its a ton of work to implement then I can understand not doing it (I
> dont know what it would take to implement). i'm just trying to say it would
> be a nicer api :) it seems from my perspective that it would be easy for
> cordova to tell the browser that cordova is present and it would save app
> developers from having to use yet another hacky technique.
>

Re: Determining if "you're in cordova"

Posted by Max Ogden <ma...@maxogden.com>.
if cordova polyfilled standard apis for everything it wouldn't be cordovas
problem. but right now there are only-in-cordova APIs that I need to use if
i'm in cordova. it would be more convenient for me as an app developer if
there was a supported way to know i'm in cordova.

I can keep looking at window.location.href and make sure to always run a
local web server for development (and never open the file directly on my
dev machine) but the point here is that doing those things is more pitfall
prone and less user friendly for new devs than doing "if
(navigator.inCordova)".

if its a ton of work to implement then I can understand not doing it (I
dont know what it would take to implement). i'm just trying to say it would
be a nicer api :) it seems from my perspective that it would be easy for
cordova to tell the browser that cordova is present and it would save app
developers from having to use yet another hacky technique.

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
I'm of the opinion this isn't a Cordova problem----but I do think
device capabilities introspection is. (Which is related.)

On Mon, Dec 3, 2012 at 11:45 PM, Gord Tanner <gt...@gmail.com> wrote:
> I am having a hard time making this seem like a Cordova problem.
>
> There are many different and easy ways to fix this for the developer but I can't see a good way for us to handle it.
>
> Do we create a Cordova.web.js that a developer can include on their server?
>
> It would enable as much as it can (geo, accel via devicemotion) and fire deviceready?
>
> Sent from my iPhone
>
> On 2012-12-03, at 6:30 PM, Max Ogden <ma...@maxogden.com> wrote:
>
>> actual code from gather:
>>
>>  if (inBrowser()) setTimeout(function() {
>>    app.emit('deviceReady')
>>  }, 50)
>>
>> right now inBrowser looks at window.location.href and fires the event if it
>> isnt in phonegap. but I use the inBrowser function elsewhere to determine
>> what login strategy to use (see my previous messages).
>>
>> if phonegap fires deviceready for me I still won't know if i'm in phonegap
>> or not
>>
>>
>>
>> On Mon, Dec 3, 2012 at 3:06 PM, Brian LeRoux <b...@brian.io> wrote:
>>
>>> So, would that not be deviceready? (I get that those apps that run in
>>> browser probably fake this event but, if thats the case, then the
>>> faking would be a userland place to put that sort of thing.)
>>>
>>> On Mon, Dec 3, 2012 at 10:54 PM, Max Ogden <ma...@maxogden.com> wrote:
>>>> I dont think modifying the UA is a good idea but I strongly believe that
>>>> cordova needs to set *something* that is immediately available from
>>> browser
>>>> JS on app load that says "hi you're running in cordova"
>>>>
>>>>
>>>> On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
>>>>
>>>>> 1) Set a specific UA string like the wikimedia guys do (even tough they
>>> do
>>>>> it for other reasons).
>>>>> 2) I remember us talking about a capabilities api. Not sure what
>>> transpired
>>>>> from that discussion.
>>>>>
>>>>>
>>>>> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>>>>>
>>>>>> Back to our original thread. I'm seeing a couple of scenarios.
>>>>>>
>>>>>> 1. wants to do analytics reporting (needs user agent)
>>>>>> 2. wants to do be capability responsive (needs to see if there are
>>>>>> device apis, usually a specific capability/api combo such as camera)
>>>>>>
>>>>>> Thoughts?
>>>>>>
>>>>>>
>>>>>> On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
>>>>>> <si...@gmail.com> wrote:
>>>>>>> Yup, window.open(url, "_blank") will load the InAppBrowser which is
>>>>>>> basically a renamed ChildBrowser that actually follows a spec for
>>>>>>> events.
>>>>>>> Simon Mac Donald
>>>>>>> http://hi.im/simonmacdonald
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>>>>>>>> In Gather we have a login page that uses childbrowser popup windows
>>>>> for
>>>>>>>> oauth if its running in phonegap or popup windows in javascript if
>>> in
>>>>>>>> browser. It would be nice childbrowser polyfilled target="_blank"
>>>>>> (which I
>>>>>>>> understand is happening in the future) but as for now the
>>> heuristics
>>>>> for
>>>>>>>> detecting which strategy to use boil down to sniffing
>>>>>> window.location.href
>>>>>>>> which isn't ideal:
>>>>>>>>
>>>>>>>> - if I open my apps index.html in chrome it will have a file:// url
>>>>> but
>>>>>>>> wont be in phonegap.
>>>>>>>> - if I hardcode a domain into my app so that it knows if it is
>>> running
>>>>>> from
>>>>>>>> a server its another thing to remember to update every time the
>>> domain
>>>>>> name
>>>>>>>> changes
>>>>>>>> - I already do conditional loading of stylesheets and JS based on
>>> user
>>>>>>>> agent. I think it would be super useful if there was a user agent
>>>>>>>> equivalent for cordova so the code could decide what to do based on
>>>>>>>> environment and not guesses based on href
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>>>>>>>>
>>>>>>>>> Eh Fil, is this so they can detect if they have device apis
>>>>> ultimately?
>>>>>>>>>
>>>>>>>>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <
>>> curtis.bryce@gmail.com
>>>>>>
>>>>>>>>> wrote:
>>>>>>>>>> I think the answer depends upon when the app checks to see if
>>> it is
>>>>>>>>>> running in cordova webview.  If it is loading a remote url with
>>>>>> remote
>>>>>>>>>> cordova.js, then the native side will become available well
>>> before
>>>>>>>>>> cordova.js finished loading.  So, I would either check for
>>>>>>>>>> device.cordova or register for deviceready and wait for it to
>>> fire.
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gtanner@gmail.com
>>>>
>>>>>> wrote:
>>>>>>>>>>> +1
>>>>>>>>>>>
>>>>>>>>>>> This isn't a platform issue but rather a developer issue
>>>>>>>>>>>
>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>>
>>>>>>>>>>> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com>
>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Presumably the developer knows the url of their own server, so
>>>>>>>>>>>> wouldn't it be easier to just test for that in
>>> window.location?
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <
>>> purplecabbage@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>>>> So the bigger question then is how to handle the differences
>>> ...
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
>>>>> wrote:
>>>>>>>>>>>>>> It is to run a single codebase (or as close to it as
>>> possible
>>>>>> minus
>>>>>>>>> the
>>>>>>>>>>>>>> differences in cordova.js) across web and cordova apps.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com>
>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Can we back up and discuss the goal?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Is it to use the same code on the server + inside an app (
>>>>> that
>>>>>> is
>>>>>>>>>>>>>>> packaged for multiple platforms ) ?
>>>>>>>>>>>>>>> OR
>>>>>>>>>>>>>>> Is it to load an app on multiple devices all served by the
>>>>> same
>>>>>>>>> server?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <
>>> shazron@gmail.com>
>>>>>> wrote:
>>>>>>>>>>>>>>>> Its yucky and may break in a future platform version, but
>>>>> since
>>>>>>>>> each
>>>>>>>>>>>>>>>> platform requires its own cordova.js -- then each platform
>>>>>> could
>>>>>>>>> define
>>>>>>>>>>>>>>>> its
>>>>>>>>>>>>>>>> own cordova.isWebView?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> wp7 is x-wmapp
>>>>>>>>>>>>>>>> iOS is file://
>>>>>>>>>>>>>>>> BB is http://localhost
>>>>>>>>>>>>>>>> Android is ?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
>>>>>> purplecabbage@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>>>>>>>>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> So file:// will not work
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> There are probably numerous other approches ...
>>>>>>>>>>>>>>>>> deviceready will/should never fire, but that is
>>> difficult to
>>>>>> test
>>>>>>>>> for,
>>>>>>>>>>>>>>>>> because it could just be taking a real long time.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I see many issues with this though:
>>>>>>>>>>>>>>>>> - each platform still requires it's own cordova.js, so
>>> this
>>>>>> would
>>>>>>>>> only
>>>>>>>>>>>>>>>>> work with 1 platform + a webserver, so no idea we come up
>>>>> for
>>>>>> this
>>>>>>>>>>>>>>>>> will solve the bigger problem.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <
>>> shazron@gmail.com
>>>>>>
>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>> document.location starts with http://localhost OR
>>> starts
>>>>>> with
>>>>>>>>> file://
>>>>>>>>>>>>>>>>> then?
>>>>>>>>>>>>>>>>>> ;)
>>>>>>>>>>>>>>>>>> In any case, any js variable that we could set can be
>>>>>> overridden
>>>>>>>>> of
>>>>>>>>>>>>>>>>> course.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <
>>> fil@adobe.com>
>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> I think in BB WEbWorks you get
>>>>>>>>> http://localhost/somethingsoemthing
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com>
>>> wrote:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>>>>>>>>> document.location
>>>>>>>>>>>>>>>>> starts
>>>>>>>>>>>>>>>>>>>> with file:// ?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>> risingj.com
>>>

Re: Determining if "you're in cordova"

Posted by Gord Tanner <gt...@gmail.com>.
I am having a hard time making this seem like a Cordova problem.

There are many different and easy ways to fix this for the developer but I can't see a good way for us to handle it.

Do we create a Cordova.web.js that a developer can include on their server?

It would enable as much as it can (geo, accel via devicemotion) and fire deviceready?

Sent from my iPhone

On 2012-12-03, at 6:30 PM, Max Ogden <ma...@maxogden.com> wrote:

> actual code from gather:
> 
>  if (inBrowser()) setTimeout(function() {
>    app.emit('deviceReady')
>  }, 50)
> 
> right now inBrowser looks at window.location.href and fires the event if it
> isnt in phonegap. but I use the inBrowser function elsewhere to determine
> what login strategy to use (see my previous messages).
> 
> if phonegap fires deviceready for me I still won't know if i'm in phonegap
> or not
> 
> 
> 
> On Mon, Dec 3, 2012 at 3:06 PM, Brian LeRoux <b...@brian.io> wrote:
> 
>> So, would that not be deviceready? (I get that those apps that run in
>> browser probably fake this event but, if thats the case, then the
>> faking would be a userland place to put that sort of thing.)
>> 
>> On Mon, Dec 3, 2012 at 10:54 PM, Max Ogden <ma...@maxogden.com> wrote:
>>> I dont think modifying the UA is a good idea but I strongly believe that
>>> cordova needs to set *something* that is immediately available from
>> browser
>>> JS on app load that says "hi you're running in cordova"
>>> 
>>> 
>>> On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
>>> 
>>>> 1) Set a specific UA string like the wikimedia guys do (even tough they
>> do
>>>> it for other reasons).
>>>> 2) I remember us talking about a capabilities api. Not sure what
>> transpired
>>>> from that discussion.
>>>> 
>>>> 
>>>> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>>>> 
>>>>> Back to our original thread. I'm seeing a couple of scenarios.
>>>>> 
>>>>> 1. wants to do analytics reporting (needs user agent)
>>>>> 2. wants to do be capability responsive (needs to see if there are
>>>>> device apis, usually a specific capability/api combo such as camera)
>>>>> 
>>>>> Thoughts?
>>>>> 
>>>>> 
>>>>> On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
>>>>> <si...@gmail.com> wrote:
>>>>>> Yup, window.open(url, "_blank") will load the InAppBrowser which is
>>>>>> basically a renamed ChildBrowser that actually follows a spec for
>>>>>> events.
>>>>>> Simon Mac Donald
>>>>>> http://hi.im/simonmacdonald
>>>>>> 
>>>>>> 
>>>>>> On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>>>>>>> In Gather we have a login page that uses childbrowser popup windows
>>>> for
>>>>>>> oauth if its running in phonegap or popup windows in javascript if
>> in
>>>>>>> browser. It would be nice childbrowser polyfilled target="_blank"
>>>>> (which I
>>>>>>> understand is happening in the future) but as for now the
>> heuristics
>>>> for
>>>>>>> detecting which strategy to use boil down to sniffing
>>>>> window.location.href
>>>>>>> which isn't ideal:
>>>>>>> 
>>>>>>> - if I open my apps index.html in chrome it will have a file:// url
>>>> but
>>>>>>> wont be in phonegap.
>>>>>>> - if I hardcode a domain into my app so that it knows if it is
>> running
>>>>> from
>>>>>>> a server its another thing to remember to update every time the
>> domain
>>>>> name
>>>>>>> changes
>>>>>>> - I already do conditional loading of stylesheets and JS based on
>> user
>>>>>>> agent. I think it would be super useful if there was a user agent
>>>>>>> equivalent for cordova so the code could decide what to do based on
>>>>>>> environment and not guesses based on href
>>>>>>> 
>>>>>>> 
>>>>>>> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>>>>>>> 
>>>>>>>> Eh Fil, is this so they can detect if they have device apis
>>>> ultimately?
>>>>>>>> 
>>>>>>>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <
>> curtis.bryce@gmail.com
>>>>> 
>>>>>>>> wrote:
>>>>>>>>> I think the answer depends upon when the app checks to see if
>> it is
>>>>>>>>> running in cordova webview.  If it is loading a remote url with
>>>>> remote
>>>>>>>>> cordova.js, then the native side will become available well
>> before
>>>>>>>>> cordova.js finished loading.  So, I would either check for
>>>>>>>>> device.cordova or register for deviceready and wait for it to
>> fire.
>>>>>>>>> 
>>>>>>>>> On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gtanner@gmail.com
>>> 
>>>>> wrote:
>>>>>>>>>> +1
>>>>>>>>>> 
>>>>>>>>>> This isn't a platform issue but rather a developer issue
>>>>>>>>>> 
>>>>>>>>>> Sent from my iPhone
>>>>>>>>>> 
>>>>>>>>>> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com>
>> wrote:
>>>>>>>>>> 
>>>>>>>>>>> Presumably the developer knows the url of their own server, so
>>>>>>>>>>> wouldn't it be easier to just test for that in
>> window.location?
>>>>>>>>>>> 
>>>>>>>>>>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <
>> purplecabbage@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>>>> So the bigger question then is how to handle the differences
>> ...
>>>>>>>>>>>> 
>>>>>>>>>>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
>>>> wrote:
>>>>>>>>>>>>> It is to run a single codebase (or as close to it as
>> possible
>>>>> minus
>>>>>>>> the
>>>>>>>>>>>>> differences in cordova.js) across web and cordova apps.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com>
>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Can we back up and discuss the goal?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Is it to use the same code on the server + inside an app (
>>>> that
>>>>> is
>>>>>>>>>>>>>> packaged for multiple platforms ) ?
>>>>>>>>>>>>>> OR
>>>>>>>>>>>>>> Is it to load an app on multiple devices all served by the
>>>> same
>>>>>>>> server?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <
>> shazron@gmail.com>
>>>>> wrote:
>>>>>>>>>>>>>>> Its yucky and may break in a future platform version, but
>>>> since
>>>>>>>> each
>>>>>>>>>>>>>>> platform requires its own cordova.js -- then each platform
>>>>> could
>>>>>>>> define
>>>>>>>>>>>>>>> its
>>>>>>>>>>>>>>> own cordova.isWebView?
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> wp7 is x-wmapp
>>>>>>>>>>>>>>> iOS is file://
>>>>>>>>>>>>>>> BB is http://localhost
>>>>>>>>>>>>>>> Android is ?
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
>>>>> purplecabbage@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>>>>>>>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> So file:// will not work
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> There are probably numerous other approches ...
>>>>>>>>>>>>>>>> deviceready will/should never fire, but that is
>> difficult to
>>>>> test
>>>>>>>> for,
>>>>>>>>>>>>>>>> because it could just be taking a real long time.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I see many issues with this though:
>>>>>>>>>>>>>>>> - each platform still requires it's own cordova.js, so
>> this
>>>>> would
>>>>>>>> only
>>>>>>>>>>>>>>>> work with 1 platform + a webserver, so no idea we come up
>>>> for
>>>>> this
>>>>>>>>>>>>>>>> will solve the bigger problem.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <
>> shazron@gmail.com
>>>>> 
>>>>>>>> wrote:
>>>>>>>>>>>>>>>>> document.location starts with http://localhost OR
>> starts
>>>>> with
>>>>>>>> file://
>>>>>>>>>>>>>>>> then?
>>>>>>>>>>>>>>>>> ;)
>>>>>>>>>>>>>>>>> In any case, any js variable that we could set can be
>>>>> overridden
>>>>>>>> of
>>>>>>>>>>>>>>>> course.
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <
>> fil@adobe.com>
>>>>>>>> wrote:
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I think in BB WEbWorks you get
>>>>>>>> http://localhost/somethingsoemthing
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com>
>> wrote:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>>>>>>>> document.location
>>>>>>>>>>>>>>>> starts
>>>>>>>>>>>>>>>>>>> with file:// ?
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> --
>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>> risingj.com
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> --
>>>>>>>>>>> @purplecabbage
>>>>>>>>>>> risingj.com
>> 

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
But the deviceready event is unique to Cordova distributions so, my
point is, you have that code in user land already so it makes sense to
keep it there. (To me.)

Is this just something you'd prefer we handled though? Something that
makes inBrowser() tidier?


On Mon, Dec 3, 2012 at 11:30 PM, Max Ogden <ma...@maxogden.com> wrote:
> actual code from gather:
>
>   if (inBrowser()) setTimeout(function() {
>     app.emit('deviceReady')
>   }, 50)
>
> right now inBrowser looks at window.location.href and fires the event if it
> isnt in phonegap. but I use the inBrowser function elsewhere to determine
> what login strategy to use (see my previous messages).
>
> if phonegap fires deviceready for me I still won't know if i'm in phonegap
> or not
>
>
>
> On Mon, Dec 3, 2012 at 3:06 PM, Brian LeRoux <b...@brian.io> wrote:
>
>> So, would that not be deviceready? (I get that those apps that run in
>> browser probably fake this event but, if thats the case, then the
>> faking would be a userland place to put that sort of thing.)
>>
>> On Mon, Dec 3, 2012 at 10:54 PM, Max Ogden <ma...@maxogden.com> wrote:
>> > I dont think modifying the UA is a good idea but I strongly believe that
>> > cordova needs to set *something* that is immediately available from
>> browser
>> > JS on app load that says "hi you're running in cordova"
>> >
>> >
>> > On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
>> >
>> >> 1) Set a specific UA string like the wikimedia guys do (even tough they
>> do
>> >> it for other reasons).
>> >> 2) I remember us talking about a capabilities api. Not sure what
>> transpired
>> >> from that discussion.
>> >>
>> >>
>> >> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>> >>
>> >> > Back to our original thread. I'm seeing a couple of scenarios.
>> >> >
>> >> > 1. wants to do analytics reporting (needs user agent)
>> >> > 2. wants to do be capability responsive (needs to see if there are
>> >> > device apis, usually a specific capability/api combo such as camera)
>> >> >
>> >> > Thoughts?
>> >> >
>> >> >
>> >> > On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
>> >> > <si...@gmail.com> wrote:
>> >> > > Yup, window.open(url, "_blank") will load the InAppBrowser which is
>> >> > > basically a renamed ChildBrowser that actually follows a spec for
>> >> > > events.
>> >> > > Simon Mac Donald
>> >> > > http://hi.im/simonmacdonald
>> >> > >
>> >> > >
>> >> > > On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>> >> > >> In Gather we have a login page that uses childbrowser popup windows
>> >> for
>> >> > >> oauth if its running in phonegap or popup windows in javascript if
>> in
>> >> > >> browser. It would be nice childbrowser polyfilled target="_blank"
>> >> > (which I
>> >> > >> understand is happening in the future) but as for now the
>> heuristics
>> >> for
>> >> > >> detecting which strategy to use boil down to sniffing
>> >> > window.location.href
>> >> > >> which isn't ideal:
>> >> > >>
>> >> > >> - if I open my apps index.html in chrome it will have a file:// url
>> >> but
>> >> > >> wont be in phonegap.
>> >> > >> - if I hardcode a domain into my app so that it knows if it is
>> running
>> >> > from
>> >> > >> a server its another thing to remember to update every time the
>> domain
>> >> > name
>> >> > >> changes
>> >> > >> - I already do conditional loading of stylesheets and JS based on
>> user
>> >> > >> agent. I think it would be super useful if there was a user agent
>> >> > >> equivalent for cordova so the code could decide what to do based on
>> >> > >> environment and not guesses based on href
>> >> > >>
>> >> > >>
>> >> > >> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>> >> > >>
>> >> > >>> Eh Fil, is this so they can detect if they have device apis
>> >> ultimately?
>> >> > >>>
>> >> > >>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <
>> curtis.bryce@gmail.com
>> >> >
>> >> > >>> wrote:
>> >> > >>> > I think the answer depends upon when the app checks to see if
>> it is
>> >> > >>> > running in cordova webview.  If it is loading a remote url with
>> >> > remote
>> >> > >>> > cordova.js, then the native side will become available well
>> before
>> >> > >>> > cordova.js finished loading.  So, I would either check for
>> >> > >>> > device.cordova or register for deviceready and wait for it to
>> fire.
>> >> > >>> >
>> >> > >>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gtanner@gmail.com
>> >
>> >> > wrote:
>> >> > >>> >> +1
>> >> > >>> >>
>> >> > >>> >> This isn't a platform issue but rather a developer issue
>> >> > >>> >>
>> >> > >>> >> Sent from my iPhone
>> >> > >>> >>
>> >> > >>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com>
>> wrote:
>> >> > >>> >>
>> >> > >>> >>> Presumably the developer knows the url of their own server, so
>> >> > >>> >>> wouldn't it be easier to just test for that in
>> window.location?
>> >> > >>> >>>
>> >> > >>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <
>> purplecabbage@gmail.com>
>> >> > >>> wrote:
>> >> > >>> >>>> So the bigger question then is how to handle the differences
>> ...
>> >> > >>> >>>>
>> >> > >>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
>> >> wrote:
>> >> > >>> >>>>> It is to run a single codebase (or as close to it as
>> possible
>> >> > minus
>> >> > >>> the
>> >> > >>> >>>>> differences in cordova.js) across web and cordova apps.
>> >> > >>> >>>>>
>> >> > >>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com>
>> wrote:
>> >> > >>> >>>>>
>> >> > >>> >>>>>> Can we back up and discuss the goal?
>> >> > >>> >>>>>>
>> >> > >>> >>>>>> Is it to use the same code on the server + inside an app (
>> >> that
>> >> > is
>> >> > >>> >>>>>> packaged for multiple platforms ) ?
>> >> > >>> >>>>>> OR
>> >> > >>> >>>>>> Is it to load an app on multiple devices all served by the
>> >> same
>> >> > >>> server?
>> >> > >>> >>>>>>
>> >> > >>> >>>>>>
>> >> > >>> >>>>>>
>> >> > >>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <
>> shazron@gmail.com>
>> >> > wrote:
>> >> > >>> >>>>>>> Its yucky and may break in a future platform version, but
>> >> since
>> >> > >>> each
>> >> > >>> >>>>>>> platform requires its own cordova.js -- then each platform
>> >> > could
>> >> > >>> define
>> >> > >>> >>>>>>> its
>> >> > >>> >>>>>>> own cordova.isWebView?
>> >> > >>> >>>>>>>
>> >> > >>> >>>>>>> wp7 is x-wmapp
>> >> > >>> >>>>>>> iOS is file://
>> >> > >>> >>>>>>> BB is http://localhost
>> >> > >>> >>>>>>> Android is ?
>> >> > >>> >>>>>>>
>> >> > >>> >>>>>>>
>> >> > >>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
>> >> > purplecabbage@gmail.com>
>> >> > >>> wrote:
>> >> > >>> >>>>>>>
>> >> > >>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
>> >> > >>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>> So file:// will not work
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>> There are probably numerous other approches ...
>> >> > >>> >>>>>>>> deviceready will/should never fire, but that is
>> difficult to
>> >> > test
>> >> > >>> for,
>> >> > >>> >>>>>>>> because it could just be taking a real long time.
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>> I see many issues with this though:
>> >> > >>> >>>>>>>> - each platform still requires it's own cordova.js, so
>> this
>> >> > would
>> >> > >>> only
>> >> > >>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up
>> >> for
>> >> > this
>> >> > >>> >>>>>>>> will solve the bigger problem.
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <
>> shazron@gmail.com
>> >> >
>> >> > >>> wrote:
>> >> > >>> >>>>>>>>> document.location starts with http://localhost OR
>> starts
>> >> > with
>> >> > >>> file://
>> >> > >>> >>>>>>>> then?
>> >> > >>> >>>>>>>>> ;)
>> >> > >>> >>>>>>>>> In any case, any js variable that we could set can be
>> >> > overridden
>> >> > >>> of
>> >> > >>> >>>>>>>> course.
>> >> > >>> >>>>>>>>>
>> >> > >>> >>>>>>>>>
>> >> > >>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <
>> fil@adobe.com>
>> >> > >>> wrote:
>> >> > >>> >>>>>>>>>
>> >> > >>> >>>>>>>>>> I think in BB WEbWorks you get
>> >> > >>> http://localhost/somethingsoemthing
>> >> > >>> >>>>>>>>>>
>> >> > >>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com>
>> wrote:
>> >> > >>> >>>>>>>>>>
>> >> > >>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>> >> > >>> document.location
>> >> > >>> >>>>>>>> starts
>> >> > >>> >>>>>>>>>>> with file:// ?
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>>
>> >> > >>> >>>>>>>> --
>> >> > >>> >>>>>>>> @purplecabbage
>> >> > >>> >>>>>>>> risingj.com
>> >> > >>> >>>>>>
>> >> > >>> >>>>>>
>> >> > >>> >>>>>>
>> >> > >>> >>>>>> --
>> >> > >>> >>>>>> @purplecabbage
>> >> > >>> >>>>>> risingj.com
>> >> > >>> >>>>
>> >> > >>> >>>>
>> >> > >>> >>>>
>> >> > >>> >>>> --
>> >> > >>> >>>> @purplecabbage
>> >> > >>> >>>> risingj.com
>> >> > >>> >>>
>> >> > >>> >>>
>> >> > >>> >>>
>> >> > >>> >>> --
>> >> > >>> >>> @purplecabbage
>> >> > >>> >>> risingj.com
>> >> > >>>
>> >> >
>> >>
>>

Re: Determining if "you're in cordova"

Posted by Max Ogden <ma...@maxogden.com>.
actual code from gather:

  if (inBrowser()) setTimeout(function() {
    app.emit('deviceReady')
  }, 50)

right now inBrowser looks at window.location.href and fires the event if it
isnt in phonegap. but I use the inBrowser function elsewhere to determine
what login strategy to use (see my previous messages).

if phonegap fires deviceready for me I still won't know if i'm in phonegap
or not



On Mon, Dec 3, 2012 at 3:06 PM, Brian LeRoux <b...@brian.io> wrote:

> So, would that not be deviceready? (I get that those apps that run in
> browser probably fake this event but, if thats the case, then the
> faking would be a userland place to put that sort of thing.)
>
> On Mon, Dec 3, 2012 at 10:54 PM, Max Ogden <ma...@maxogden.com> wrote:
> > I dont think modifying the UA is a good idea but I strongly believe that
> > cordova needs to set *something* that is immediately available from
> browser
> > JS on app load that says "hi you're running in cordova"
> >
> >
> > On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
> >
> >> 1) Set a specific UA string like the wikimedia guys do (even tough they
> do
> >> it for other reasons).
> >> 2) I remember us talking about a capabilities api. Not sure what
> transpired
> >> from that discussion.
> >>
> >>
> >> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
> >>
> >> > Back to our original thread. I'm seeing a couple of scenarios.
> >> >
> >> > 1. wants to do analytics reporting (needs user agent)
> >> > 2. wants to do be capability responsive (needs to see if there are
> >> > device apis, usually a specific capability/api combo such as camera)
> >> >
> >> > Thoughts?
> >> >
> >> >
> >> > On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
> >> > <si...@gmail.com> wrote:
> >> > > Yup, window.open(url, "_blank") will load the InAppBrowser which is
> >> > > basically a renamed ChildBrowser that actually follows a spec for
> >> > > events.
> >> > > Simon Mac Donald
> >> > > http://hi.im/simonmacdonald
> >> > >
> >> > >
> >> > > On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> >> > >> In Gather we have a login page that uses childbrowser popup windows
> >> for
> >> > >> oauth if its running in phonegap or popup windows in javascript if
> in
> >> > >> browser. It would be nice childbrowser polyfilled target="_blank"
> >> > (which I
> >> > >> understand is happening in the future) but as for now the
> heuristics
> >> for
> >> > >> detecting which strategy to use boil down to sniffing
> >> > window.location.href
> >> > >> which isn't ideal:
> >> > >>
> >> > >> - if I open my apps index.html in chrome it will have a file:// url
> >> but
> >> > >> wont be in phonegap.
> >> > >> - if I hardcode a domain into my app so that it knows if it is
> running
> >> > from
> >> > >> a server its another thing to remember to update every time the
> domain
> >> > name
> >> > >> changes
> >> > >> - I already do conditional loading of stylesheets and JS based on
> user
> >> > >> agent. I think it would be super useful if there was a user agent
> >> > >> equivalent for cordova so the code could decide what to do based on
> >> > >> environment and not guesses based on href
> >> > >>
> >> > >>
> >> > >> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
> >> > >>
> >> > >>> Eh Fil, is this so they can detect if they have device apis
> >> ultimately?
> >> > >>>
> >> > >>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <
> curtis.bryce@gmail.com
> >> >
> >> > >>> wrote:
> >> > >>> > I think the answer depends upon when the app checks to see if
> it is
> >> > >>> > running in cordova webview.  If it is loading a remote url with
> >> > remote
> >> > >>> > cordova.js, then the native side will become available well
> before
> >> > >>> > cordova.js finished loading.  So, I would either check for
> >> > >>> > device.cordova or register for deviceready and wait for it to
> fire.
> >> > >>> >
> >> > >>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gtanner@gmail.com
> >
> >> > wrote:
> >> > >>> >> +1
> >> > >>> >>
> >> > >>> >> This isn't a platform issue but rather a developer issue
> >> > >>> >>
> >> > >>> >> Sent from my iPhone
> >> > >>> >>
> >> > >>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com>
> wrote:
> >> > >>> >>
> >> > >>> >>> Presumably the developer knows the url of their own server, so
> >> > >>> >>> wouldn't it be easier to just test for that in
> window.location?
> >> > >>> >>>
> >> > >>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <
> purplecabbage@gmail.com>
> >> > >>> wrote:
> >> > >>> >>>> So the bigger question then is how to handle the differences
> ...
> >> > >>> >>>>
> >> > >>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
> >> wrote:
> >> > >>> >>>>> It is to run a single codebase (or as close to it as
> possible
> >> > minus
> >> > >>> the
> >> > >>> >>>>> differences in cordova.js) across web and cordova apps.
> >> > >>> >>>>>
> >> > >>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com>
> wrote:
> >> > >>> >>>>>
> >> > >>> >>>>>> Can we back up and discuss the goal?
> >> > >>> >>>>>>
> >> > >>> >>>>>> Is it to use the same code on the server + inside an app (
> >> that
> >> > is
> >> > >>> >>>>>> packaged for multiple platforms ) ?
> >> > >>> >>>>>> OR
> >> > >>> >>>>>> Is it to load an app on multiple devices all served by the
> >> same
> >> > >>> server?
> >> > >>> >>>>>>
> >> > >>> >>>>>>
> >> > >>> >>>>>>
> >> > >>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <
> shazron@gmail.com>
> >> > wrote:
> >> > >>> >>>>>>> Its yucky and may break in a future platform version, but
> >> since
> >> > >>> each
> >> > >>> >>>>>>> platform requires its own cordova.js -- then each platform
> >> > could
> >> > >>> define
> >> > >>> >>>>>>> its
> >> > >>> >>>>>>> own cordova.isWebView?
> >> > >>> >>>>>>>
> >> > >>> >>>>>>> wp7 is x-wmapp
> >> > >>> >>>>>>> iOS is file://
> >> > >>> >>>>>>> BB is http://localhost
> >> > >>> >>>>>>> Android is ?
> >> > >>> >>>>>>>
> >> > >>> >>>>>>>
> >> > >>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
> >> > purplecabbage@gmail.com>
> >> > >>> wrote:
> >> > >>> >>>>>>>
> >> > >>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
> >> > >>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>> So file:// will not work
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>> There are probably numerous other approches ...
> >> > >>> >>>>>>>> deviceready will/should never fire, but that is
> difficult to
> >> > test
> >> > >>> for,
> >> > >>> >>>>>>>> because it could just be taking a real long time.
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>> I see many issues with this though:
> >> > >>> >>>>>>>> - each platform still requires it's own cordova.js, so
> this
> >> > would
> >> > >>> only
> >> > >>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up
> >> for
> >> > this
> >> > >>> >>>>>>>> will solve the bigger problem.
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <
> shazron@gmail.com
> >> >
> >> > >>> wrote:
> >> > >>> >>>>>>>>> document.location starts with http://localhost OR
> starts
> >> > with
> >> > >>> file://
> >> > >>> >>>>>>>> then?
> >> > >>> >>>>>>>>> ;)
> >> > >>> >>>>>>>>> In any case, any js variable that we could set can be
> >> > overridden
> >> > >>> of
> >> > >>> >>>>>>>> course.
> >> > >>> >>>>>>>>>
> >> > >>> >>>>>>>>>
> >> > >>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <
> fil@adobe.com>
> >> > >>> wrote:
> >> > >>> >>>>>>>>>
> >> > >>> >>>>>>>>>> I think in BB WEbWorks you get
> >> > >>> http://localhost/somethingsoemthing
> >> > >>> >>>>>>>>>>
> >> > >>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com>
> wrote:
> >> > >>> >>>>>>>>>>
> >> > >>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
> >> > >>> document.location
> >> > >>> >>>>>>>> starts
> >> > >>> >>>>>>>>>>> with file:// ?
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>>
> >> > >>> >>>>>>>> --
> >> > >>> >>>>>>>> @purplecabbage
> >> > >>> >>>>>>>> risingj.com
> >> > >>> >>>>>>
> >> > >>> >>>>>>
> >> > >>> >>>>>>
> >> > >>> >>>>>> --
> >> > >>> >>>>>> @purplecabbage
> >> > >>> >>>>>> risingj.com
> >> > >>> >>>>
> >> > >>> >>>>
> >> > >>> >>>>
> >> > >>> >>>> --
> >> > >>> >>>> @purplecabbage
> >> > >>> >>>> risingj.com
> >> > >>> >>>
> >> > >>> >>>
> >> > >>> >>>
> >> > >>> >>> --
> >> > >>> >>> @purplecabbage
> >> > >>> >>> risingj.com
> >> > >>>
> >> >
> >>
>

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
So, would that not be deviceready? (I get that those apps that run in
browser probably fake this event but, if thats the case, then the
faking would be a userland place to put that sort of thing.)

On Mon, Dec 3, 2012 at 10:54 PM, Max Ogden <ma...@maxogden.com> wrote:
> I dont think modifying the UA is a good idea but I strongly believe that
> cordova needs to set *something* that is immediately available from browser
> JS on app load that says "hi you're running in cordova"
>
>
> On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
>
>> 1) Set a specific UA string like the wikimedia guys do (even tough they do
>> it for other reasons).
>> 2) I remember us talking about a capabilities api. Not sure what transpired
>> from that discussion.
>>
>>
>> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>>
>> > Back to our original thread. I'm seeing a couple of scenarios.
>> >
>> > 1. wants to do analytics reporting (needs user agent)
>> > 2. wants to do be capability responsive (needs to see if there are
>> > device apis, usually a specific capability/api combo such as camera)
>> >
>> > Thoughts?
>> >
>> >
>> > On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
>> > <si...@gmail.com> wrote:
>> > > Yup, window.open(url, "_blank") will load the InAppBrowser which is
>> > > basically a renamed ChildBrowser that actually follows a spec for
>> > > events.
>> > > Simon Mac Donald
>> > > http://hi.im/simonmacdonald
>> > >
>> > >
>> > > On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>> > >> In Gather we have a login page that uses childbrowser popup windows
>> for
>> > >> oauth if its running in phonegap or popup windows in javascript if in
>> > >> browser. It would be nice childbrowser polyfilled target="_blank"
>> > (which I
>> > >> understand is happening in the future) but as for now the heuristics
>> for
>> > >> detecting which strategy to use boil down to sniffing
>> > window.location.href
>> > >> which isn't ideal:
>> > >>
>> > >> - if I open my apps index.html in chrome it will have a file:// url
>> but
>> > >> wont be in phonegap.
>> > >> - if I hardcode a domain into my app so that it knows if it is running
>> > from
>> > >> a server its another thing to remember to update every time the domain
>> > name
>> > >> changes
>> > >> - I already do conditional loading of stylesheets and JS based on user
>> > >> agent. I think it would be super useful if there was a user agent
>> > >> equivalent for cordova so the code could decide what to do based on
>> > >> environment and not guesses based on href
>> > >>
>> > >>
>> > >> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>> > >>
>> > >>> Eh Fil, is this so they can detect if they have device apis
>> ultimately?
>> > >>>
>> > >>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <curtis.bryce@gmail.com
>> >
>> > >>> wrote:
>> > >>> > I think the answer depends upon when the app checks to see if it is
>> > >>> > running in cordova webview.  If it is loading a remote url with
>> > remote
>> > >>> > cordova.js, then the native side will become available well before
>> > >>> > cordova.js finished loading.  So, I would either check for
>> > >>> > device.cordova or register for deviceready and wait for it to fire.
>> > >>> >
>> > >>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com>
>> > wrote:
>> > >>> >> +1
>> > >>> >>
>> > >>> >> This isn't a platform issue but rather a developer issue
>> > >>> >>
>> > >>> >> Sent from my iPhone
>> > >>> >>
>> > >>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>> > >>> >>
>> > >>> >>> Presumably the developer knows the url of their own server, so
>> > >>> >>> wouldn't it be easier to just test for that in window.location?
>> > >>> >>>
>> > >>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
>> > >>> wrote:
>> > >>> >>>> So the bigger question then is how to handle the differences ...
>> > >>> >>>>
>> > >>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
>> wrote:
>> > >>> >>>>> It is to run a single codebase (or as close to it as possible
>> > minus
>> > >>> the
>> > >>> >>>>> differences in cordova.js) across web and cordova apps.
>> > >>> >>>>>
>> > >>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>> > >>> >>>>>
>> > >>> >>>>>> Can we back up and discuss the goal?
>> > >>> >>>>>>
>> > >>> >>>>>> Is it to use the same code on the server + inside an app (
>> that
>> > is
>> > >>> >>>>>> packaged for multiple platforms ) ?
>> > >>> >>>>>> OR
>> > >>> >>>>>> Is it to load an app on multiple devices all served by the
>> same
>> > >>> server?
>> > >>> >>>>>>
>> > >>> >>>>>>
>> > >>> >>>>>>
>> > >>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com>
>> > wrote:
>> > >>> >>>>>>> Its yucky and may break in a future platform version, but
>> since
>> > >>> each
>> > >>> >>>>>>> platform requires its own cordova.js -- then each platform
>> > could
>> > >>> define
>> > >>> >>>>>>> its
>> > >>> >>>>>>> own cordova.isWebView?
>> > >>> >>>>>>>
>> > >>> >>>>>>> wp7 is x-wmapp
>> > >>> >>>>>>> iOS is file://
>> > >>> >>>>>>> BB is http://localhost
>> > >>> >>>>>>> Android is ?
>> > >>> >>>>>>>
>> > >>> >>>>>>>
>> > >>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
>> > purplecabbage@gmail.com>
>> > >>> wrote:
>> > >>> >>>>>>>
>> > >>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
>> > >>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
>> > >>> >>>>>>>>
>> > >>> >>>>>>>> So file:// will not work
>> > >>> >>>>>>>>
>> > >>> >>>>>>>> There are probably numerous other approches ...
>> > >>> >>>>>>>> deviceready will/should never fire, but that is difficult to
>> > test
>> > >>> for,
>> > >>> >>>>>>>> because it could just be taking a real long time.
>> > >>> >>>>>>>>
>> > >>> >>>>>>>>
>> > >>> >>>>>>>> I see many issues with this though:
>> > >>> >>>>>>>> - each platform still requires it's own cordova.js, so this
>> > would
>> > >>> only
>> > >>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up
>> for
>> > this
>> > >>> >>>>>>>> will solve the bigger problem.
>> > >>> >>>>>>>>
>> > >>> >>>>>>>>
>> > >>> >>>>>>>>
>> > >>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <shazron@gmail.com
>> >
>> > >>> wrote:
>> > >>> >>>>>>>>> document.location starts with http://localhost OR starts
>> > with
>> > >>> file://
>> > >>> >>>>>>>> then?
>> > >>> >>>>>>>>> ;)
>> > >>> >>>>>>>>> In any case, any js variable that we could set can be
>> > overridden
>> > >>> of
>> > >>> >>>>>>>> course.
>> > >>> >>>>>>>>>
>> > >>> >>>>>>>>>
>> > >>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
>> > >>> wrote:
>> > >>> >>>>>>>>>
>> > >>> >>>>>>>>>> I think in BB WEbWorks you get
>> > >>> http://localhost/somethingsoemthing
>> > >>> >>>>>>>>>>
>> > >>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>> > >>> >>>>>>>>>>
>> > >>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>> > >>> document.location
>> > >>> >>>>>>>> starts
>> > >>> >>>>>>>>>>> with file:// ?
>> > >>> >>>>>>>>
>> > >>> >>>>>>>>
>> > >>> >>>>>>>>
>> > >>> >>>>>>>> --
>> > >>> >>>>>>>> @purplecabbage
>> > >>> >>>>>>>> risingj.com
>> > >>> >>>>>>
>> > >>> >>>>>>
>> > >>> >>>>>>
>> > >>> >>>>>> --
>> > >>> >>>>>> @purplecabbage
>> > >>> >>>>>> risingj.com
>> > >>> >>>>
>> > >>> >>>>
>> > >>> >>>>
>> > >>> >>>> --
>> > >>> >>>> @purplecabbage
>> > >>> >>>> risingj.com
>> > >>> >>>
>> > >>> >>>
>> > >>> >>>
>> > >>> >>> --
>> > >>> >>> @purplecabbage
>> > >>> >>> risingj.com
>> > >>>
>> >
>>

Re: Determining if "you're in cordova"

Posted by Gord Tanner <gt...@gmail.com>.
Is what people in the browser wanting the deviceready event to fire?

Sent from my iPhone

On 2012-12-03, at 5:54 PM, Max Ogden <ma...@maxogden.com> wrote:

> I dont think modifying the UA is a good idea but I strongly believe that
> cordova needs to set *something* that is immediately available from browser
> JS on app load that says "hi you're running in cordova"
> 
> 
> On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:
> 
>> 1) Set a specific UA string like the wikimedia guys do (even tough they do
>> it for other reasons).
>> 2) I remember us talking about a capabilities api. Not sure what transpired
>> from that discussion.
>> 
>> 
>> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>> 
>>> Back to our original thread. I'm seeing a couple of scenarios.
>>> 
>>> 1. wants to do analytics reporting (needs user agent)
>>> 2. wants to do be capability responsive (needs to see if there are
>>> device apis, usually a specific capability/api combo such as camera)
>>> 
>>> Thoughts?
>>> 
>>> 
>>> On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
>>> <si...@gmail.com> wrote:
>>>> Yup, window.open(url, "_blank") will load the InAppBrowser which is
>>>> basically a renamed ChildBrowser that actually follows a spec for
>>>> events.
>>>> Simon Mac Donald
>>>> http://hi.im/simonmacdonald
>>>> 
>>>> 
>>>> On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>>>>> In Gather we have a login page that uses childbrowser popup windows
>> for
>>>>> oauth if its running in phonegap or popup windows in javascript if in
>>>>> browser. It would be nice childbrowser polyfilled target="_blank"
>>> (which I
>>>>> understand is happening in the future) but as for now the heuristics
>> for
>>>>> detecting which strategy to use boil down to sniffing
>>> window.location.href
>>>>> which isn't ideal:
>>>>> 
>>>>> - if I open my apps index.html in chrome it will have a file:// url
>> but
>>>>> wont be in phonegap.
>>>>> - if I hardcode a domain into my app so that it knows if it is running
>>> from
>>>>> a server its another thing to remember to update every time the domain
>>> name
>>>>> changes
>>>>> - I already do conditional loading of stylesheets and JS based on user
>>>>> agent. I think it would be super useful if there was a user agent
>>>>> equivalent for cordova so the code could decide what to do based on
>>>>> environment and not guesses based on href
>>>>> 
>>>>> 
>>>>> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>>>>> 
>>>>>> Eh Fil, is this so they can detect if they have device apis
>> ultimately?
>>>>>> 
>>>>>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <curtis.bryce@gmail.com
>>> 
>>>>>> wrote:
>>>>>>> I think the answer depends upon when the app checks to see if it is
>>>>>>> running in cordova webview.  If it is loading a remote url with
>>> remote
>>>>>>> cordova.js, then the native side will become available well before
>>>>>>> cordova.js finished loading.  So, I would either check for
>>>>>>> device.cordova or register for deviceready and wait for it to fire.
>>>>>>> 
>>>>>>> On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com>
>>> wrote:
>>>>>>>> +1
>>>>>>>> 
>>>>>>>> This isn't a platform issue but rather a developer issue
>>>>>>>> 
>>>>>>>> Sent from my iPhone
>>>>>>>> 
>>>>>>>> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>>>>>>>> 
>>>>>>>>> Presumably the developer knows the url of their own server, so
>>>>>>>>> wouldn't it be easier to just test for that in window.location?
>>>>>>>>> 
>>>>>>>>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
>>>>>> wrote:
>>>>>>>>>> So the bigger question then is how to handle the differences ...
>>>>>>>>>> 
>>>>>>>>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
>> wrote:
>>>>>>>>>>> It is to run a single codebase (or as close to it as possible
>>> minus
>>>>>> the
>>>>>>>>>>> differences in cordova.js) across web and cordova apps.
>>>>>>>>>>> 
>>>>>>>>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> Can we back up and discuss the goal?
>>>>>>>>>>>> 
>>>>>>>>>>>> Is it to use the same code on the server + inside an app (
>> that
>>> is
>>>>>>>>>>>> packaged for multiple platforms ) ?
>>>>>>>>>>>> OR
>>>>>>>>>>>> Is it to load an app on multiple devices all served by the
>> same
>>>>>> server?
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com>
>>> wrote:
>>>>>>>>>>>>> Its yucky and may break in a future platform version, but
>> since
>>>>>> each
>>>>>>>>>>>>> platform requires its own cordova.js -- then each platform
>>> could
>>>>>> define
>>>>>>>>>>>>> its
>>>>>>>>>>>>> own cordova.isWebView?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> wp7 is x-wmapp
>>>>>>>>>>>>> iOS is file://
>>>>>>>>>>>>> BB is http://localhost
>>>>>>>>>>>>> Android is ?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
>>> purplecabbage@gmail.com>
>>>>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>>>>>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> So file:// will not work
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> There are probably numerous other approches ...
>>>>>>>>>>>>>> deviceready will/should never fire, but that is difficult to
>>> test
>>>>>> for,
>>>>>>>>>>>>>> because it could just be taking a real long time.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I see many issues with this though:
>>>>>>>>>>>>>> - each platform still requires it's own cordova.js, so this
>>> would
>>>>>> only
>>>>>>>>>>>>>> work with 1 platform + a webserver, so no idea we come up
>> for
>>> this
>>>>>>>>>>>>>> will solve the bigger problem.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <shazron@gmail.com
>>> 
>>>>>> wrote:
>>>>>>>>>>>>>>> document.location starts with http://localhost OR starts
>>> with
>>>>>> file://
>>>>>>>>>>>>>> then?
>>>>>>>>>>>>>>> ;)
>>>>>>>>>>>>>>> In any case, any js variable that we could set can be
>>> overridden
>>>>>> of
>>>>>>>>>>>>>> course.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
>>>>>> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I think in BB WEbWorks you get
>>>>>> http://localhost/somethingsoemthing
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>>>>>> document.location
>>>>>>>>>>>>>> starts
>>>>>>>>>>>>>>>>> with file:// ?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>>>> risingj.com
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> --
>>>>>>>>>>>> @purplecabbage
>>>>>>>>>>>> risingj.com
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> --
>>>>>>>>>> @purplecabbage
>>>>>>>>>> risingj.com
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> @purplecabbage
>>>>>>>>> risingj.com
>> 

Re: Determining if "you're in cordova"

Posted by Max Ogden <ma...@maxogden.com>.
I dont think modifying the UA is a good idea but I strongly believe that
cordova needs to set *something* that is immediately available from browser
JS on app load that says "hi you're running in cordova"


On Mon, Dec 3, 2012 at 1:31 PM, Anis KADRI <an...@gmail.com> wrote:

> 1) Set a specific UA string like the wikimedia guys do (even tough they do
> it for other reasons).
> 2) I remember us talking about a capabilities api. Not sure what transpired
> from that discussion.
>
>
> On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > Back to our original thread. I'm seeing a couple of scenarios.
> >
> > 1. wants to do analytics reporting (needs user agent)
> > 2. wants to do be capability responsive (needs to see if there are
> > device apis, usually a specific capability/api combo such as camera)
> >
> > Thoughts?
> >
> >
> > On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
> > <si...@gmail.com> wrote:
> > > Yup, window.open(url, "_blank") will load the InAppBrowser which is
> > > basically a renamed ChildBrowser that actually follows a spec for
> > > events.
> > > Simon Mac Donald
> > > http://hi.im/simonmacdonald
> > >
> > >
> > > On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> > >> In Gather we have a login page that uses childbrowser popup windows
> for
> > >> oauth if its running in phonegap or popup windows in javascript if in
> > >> browser. It would be nice childbrowser polyfilled target="_blank"
> > (which I
> > >> understand is happening in the future) but as for now the heuristics
> for
> > >> detecting which strategy to use boil down to sniffing
> > window.location.href
> > >> which isn't ideal:
> > >>
> > >> - if I open my apps index.html in chrome it will have a file:// url
> but
> > >> wont be in phonegap.
> > >> - if I hardcode a domain into my app so that it knows if it is running
> > from
> > >> a server its another thing to remember to update every time the domain
> > name
> > >> changes
> > >> - I already do conditional loading of stylesheets and JS based on user
> > >> agent. I think it would be super useful if there was a user agent
> > >> equivalent for cordova so the code could decide what to do based on
> > >> environment and not guesses based on href
> > >>
> > >>
> > >> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
> > >>
> > >>> Eh Fil, is this so they can detect if they have device apis
> ultimately?
> > >>>
> > >>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <curtis.bryce@gmail.com
> >
> > >>> wrote:
> > >>> > I think the answer depends upon when the app checks to see if it is
> > >>> > running in cordova webview.  If it is loading a remote url with
> > remote
> > >>> > cordova.js, then the native side will become available well before
> > >>> > cordova.js finished loading.  So, I would either check for
> > >>> > device.cordova or register for deviceready and wait for it to fire.
> > >>> >
> > >>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com>
> > wrote:
> > >>> >> +1
> > >>> >>
> > >>> >> This isn't a platform issue but rather a developer issue
> > >>> >>
> > >>> >> Sent from my iPhone
> > >>> >>
> > >>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
> > >>> >>
> > >>> >>> Presumably the developer knows the url of their own server, so
> > >>> >>> wouldn't it be easier to just test for that in window.location?
> > >>> >>>
> > >>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
> > >>> wrote:
> > >>> >>>> So the bigger question then is how to handle the differences ...
> > >>> >>>>
> > >>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com>
> wrote:
> > >>> >>>>> It is to run a single codebase (or as close to it as possible
> > minus
> > >>> the
> > >>> >>>>> differences in cordova.js) across web and cordova apps.
> > >>> >>>>>
> > >>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
> > >>> >>>>>
> > >>> >>>>>> Can we back up and discuss the goal?
> > >>> >>>>>>
> > >>> >>>>>> Is it to use the same code on the server + inside an app (
> that
> > is
> > >>> >>>>>> packaged for multiple platforms ) ?
> > >>> >>>>>> OR
> > >>> >>>>>> Is it to load an app on multiple devices all served by the
> same
> > >>> server?
> > >>> >>>>>>
> > >>> >>>>>>
> > >>> >>>>>>
> > >>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com>
> > wrote:
> > >>> >>>>>>> Its yucky and may break in a future platform version, but
> since
> > >>> each
> > >>> >>>>>>> platform requires its own cordova.js -- then each platform
> > could
> > >>> define
> > >>> >>>>>>> its
> > >>> >>>>>>> own cordova.isWebView?
> > >>> >>>>>>>
> > >>> >>>>>>> wp7 is x-wmapp
> > >>> >>>>>>> iOS is file://
> > >>> >>>>>>> BB is http://localhost
> > >>> >>>>>>> Android is ?
> > >>> >>>>>>>
> > >>> >>>>>>>
> > >>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
> > purplecabbage@gmail.com>
> > >>> wrote:
> > >>> >>>>>>>
> > >>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
> > >>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
> > >>> >>>>>>>>
> > >>> >>>>>>>> So file:// will not work
> > >>> >>>>>>>>
> > >>> >>>>>>>> There are probably numerous other approches ...
> > >>> >>>>>>>> deviceready will/should never fire, but that is difficult to
> > test
> > >>> for,
> > >>> >>>>>>>> because it could just be taking a real long time.
> > >>> >>>>>>>>
> > >>> >>>>>>>>
> > >>> >>>>>>>> I see many issues with this though:
> > >>> >>>>>>>> - each platform still requires it's own cordova.js, so this
> > would
> > >>> only
> > >>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up
> for
> > this
> > >>> >>>>>>>> will solve the bigger problem.
> > >>> >>>>>>>>
> > >>> >>>>>>>>
> > >>> >>>>>>>>
> > >>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <shazron@gmail.com
> >
> > >>> wrote:
> > >>> >>>>>>>>> document.location starts with http://localhost OR starts
> > with
> > >>> file://
> > >>> >>>>>>>> then?
> > >>> >>>>>>>>> ;)
> > >>> >>>>>>>>> In any case, any js variable that we could set can be
> > overridden
> > >>> of
> > >>> >>>>>>>> course.
> > >>> >>>>>>>>>
> > >>> >>>>>>>>>
> > >>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
> > >>> wrote:
> > >>> >>>>>>>>>
> > >>> >>>>>>>>>> I think in BB WEbWorks you get
> > >>> http://localhost/somethingsoemthing
> > >>> >>>>>>>>>>
> > >>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
> > >>> >>>>>>>>>>
> > >>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
> > >>> document.location
> > >>> >>>>>>>> starts
> > >>> >>>>>>>>>>> with file:// ?
> > >>> >>>>>>>>
> > >>> >>>>>>>>
> > >>> >>>>>>>>
> > >>> >>>>>>>> --
> > >>> >>>>>>>> @purplecabbage
> > >>> >>>>>>>> risingj.com
> > >>> >>>>>>
> > >>> >>>>>>
> > >>> >>>>>>
> > >>> >>>>>> --
> > >>> >>>>>> @purplecabbage
> > >>> >>>>>> risingj.com
> > >>> >>>>
> > >>> >>>>
> > >>> >>>>
> > >>> >>>> --
> > >>> >>>> @purplecabbage
> > >>> >>>> risingj.com
> > >>> >>>
> > >>> >>>
> > >>> >>>
> > >>> >>> --
> > >>> >>> @purplecabbage
> > >>> >>> risingj.com
> > >>>
> >
>

Re: Determining if "you're in cordova"

Posted by Anis KADRI <an...@gmail.com>.
1) Set a specific UA string like the wikimedia guys do (even tough they do
it for other reasons).
2) I remember us talking about a capabilities api. Not sure what transpired
from that discussion.


On Mon, Dec 3, 2012 at 1:29 PM, Brian LeRoux <b...@brian.io> wrote:

> Back to our original thread. I'm seeing a couple of scenarios.
>
> 1. wants to do analytics reporting (needs user agent)
> 2. wants to do be capability responsive (needs to see if there are
> device apis, usually a specific capability/api combo such as camera)
>
> Thoughts?
>
>
> On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
> <si...@gmail.com> wrote:
> > Yup, window.open(url, "_blank") will load the InAppBrowser which is
> > basically a renamed ChildBrowser that actually follows a spec for
> > events.
> > Simon Mac Donald
> > http://hi.im/simonmacdonald
> >
> >
> > On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> >> In Gather we have a login page that uses childbrowser popup windows for
> >> oauth if its running in phonegap or popup windows in javascript if in
> >> browser. It would be nice childbrowser polyfilled target="_blank"
> (which I
> >> understand is happening in the future) but as for now the heuristics for
> >> detecting which strategy to use boil down to sniffing
> window.location.href
> >> which isn't ideal:
> >>
> >> - if I open my apps index.html in chrome it will have a file:// url but
> >> wont be in phonegap.
> >> - if I hardcode a domain into my app so that it knows if it is running
> from
> >> a server its another thing to remember to update every time the domain
> name
> >> changes
> >> - I already do conditional loading of stylesheets and JS based on user
> >> agent. I think it would be super useful if there was a user agent
> >> equivalent for cordova so the code could decide what to do based on
> >> environment and not guesses based on href
> >>
> >>
> >> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
> >>
> >>> Eh Fil, is this so they can detect if they have device apis ultimately?
> >>>
> >>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <cu...@gmail.com>
> >>> wrote:
> >>> > I think the answer depends upon when the app checks to see if it is
> >>> > running in cordova webview.  If it is loading a remote url with
> remote
> >>> > cordova.js, then the native side will become available well before
> >>> > cordova.js finished loading.  So, I would either check for
> >>> > device.cordova or register for deviceready and wait for it to fire.
> >>> >
> >>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com>
> wrote:
> >>> >> +1
> >>> >>
> >>> >> This isn't a platform issue but rather a developer issue
> >>> >>
> >>> >> Sent from my iPhone
> >>> >>
> >>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
> >>> >>
> >>> >>> Presumably the developer knows the url of their own server, so
> >>> >>> wouldn't it be easier to just test for that in window.location?
> >>> >>>
> >>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
> >>> wrote:
> >>> >>>> So the bigger question then is how to handle the differences ...
> >>> >>>>
> >>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
> >>> >>>>> It is to run a single codebase (or as close to it as possible
> minus
> >>> the
> >>> >>>>> differences in cordova.js) across web and cordova apps.
> >>> >>>>>
> >>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
> >>> >>>>>
> >>> >>>>>> Can we back up and discuss the goal?
> >>> >>>>>>
> >>> >>>>>> Is it to use the same code on the server + inside an app ( that
> is
> >>> >>>>>> packaged for multiple platforms ) ?
> >>> >>>>>> OR
> >>> >>>>>> Is it to load an app on multiple devices all served by the same
> >>> server?
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com>
> wrote:
> >>> >>>>>>> Its yucky and may break in a future platform version, but since
> >>> each
> >>> >>>>>>> platform requires its own cordova.js -- then each platform
> could
> >>> define
> >>> >>>>>>> its
> >>> >>>>>>> own cordova.isWebView?
> >>> >>>>>>>
> >>> >>>>>>> wp7 is x-wmapp
> >>> >>>>>>> iOS is file://
> >>> >>>>>>> BB is http://localhost
> >>> >>>>>>> Android is ?
> >>> >>>>>>>
> >>> >>>>>>>
> >>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <
> purplecabbage@gmail.com>
> >>> wrote:
> >>> >>>>>>>
> >>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
> >>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
> >>> >>>>>>>>
> >>> >>>>>>>> So file:// will not work
> >>> >>>>>>>>
> >>> >>>>>>>> There are probably numerous other approches ...
> >>> >>>>>>>> deviceready will/should never fire, but that is difficult to
> test
> >>> for,
> >>> >>>>>>>> because it could just be taking a real long time.
> >>> >>>>>>>>
> >>> >>>>>>>>
> >>> >>>>>>>> I see many issues with this though:
> >>> >>>>>>>> - each platform still requires it's own cordova.js, so this
> would
> >>> only
> >>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up for
> this
> >>> >>>>>>>> will solve the bigger problem.
> >>> >>>>>>>>
> >>> >>>>>>>>
> >>> >>>>>>>>
> >>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com>
> >>> wrote:
> >>> >>>>>>>>> document.location starts with http://localhost OR starts
> with
> >>> file://
> >>> >>>>>>>> then?
> >>> >>>>>>>>> ;)
> >>> >>>>>>>>> In any case, any js variable that we could set can be
> overridden
> >>> of
> >>> >>>>>>>> course.
> >>> >>>>>>>>>
> >>> >>>>>>>>>
> >>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
> >>> wrote:
> >>> >>>>>>>>>
> >>> >>>>>>>>>> I think in BB WEbWorks you get
> >>> http://localhost/somethingsoemthing
> >>> >>>>>>>>>>
> >>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
> >>> >>>>>>>>>>
> >>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
> >>> document.location
> >>> >>>>>>>> starts
> >>> >>>>>>>>>>> with file:// ?
> >>> >>>>>>>>
> >>> >>>>>>>>
> >>> >>>>>>>>
> >>> >>>>>>>> --
> >>> >>>>>>>> @purplecabbage
> >>> >>>>>>>> risingj.com
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>> --
> >>> >>>>>> @purplecabbage
> >>> >>>>>> risingj.com
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>> >>>> --
> >>> >>>> @purplecabbage
> >>> >>>> risingj.com
> >>> >>>
> >>> >>>
> >>> >>>
> >>> >>> --
> >>> >>> @purplecabbage
> >>> >>> risingj.com
> >>>
>

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
Back to our original thread. I'm seeing a couple of scenarios.

1. wants to do analytics reporting (needs user agent)
2. wants to do be capability responsive (needs to see if there are
device apis, usually a specific capability/api combo such as camera)

Thoughts?


On Mon, Dec 3, 2012 at 9:10 PM, Simon MacDonald
<si...@gmail.com> wrote:
> Yup, window.open(url, "_blank") will load the InAppBrowser which is
> basically a renamed ChildBrowser that actually follows a spec for
> events.
> Simon Mac Donald
> http://hi.im/simonmacdonald
>
>
> On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
>> In Gather we have a login page that uses childbrowser popup windows for
>> oauth if its running in phonegap or popup windows in javascript if in
>> browser. It would be nice childbrowser polyfilled target="_blank" (which I
>> understand is happening in the future) but as for now the heuristics for
>> detecting which strategy to use boil down to sniffing window.location.href
>> which isn't ideal:
>>
>> - if I open my apps index.html in chrome it will have a file:// url but
>> wont be in phonegap.
>> - if I hardcode a domain into my app so that it knows if it is running from
>> a server its another thing to remember to update every time the domain name
>> changes
>> - I already do conditional loading of stylesheets and JS based on user
>> agent. I think it would be super useful if there was a user agent
>> equivalent for cordova so the code could decide what to do based on
>> environment and not guesses based on href
>>
>>
>> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>>
>>> Eh Fil, is this so they can detect if they have device apis ultimately?
>>>
>>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <cu...@gmail.com>
>>> wrote:
>>> > I think the answer depends upon when the app checks to see if it is
>>> > running in cordova webview.  If it is loading a remote url with remote
>>> > cordova.js, then the native side will become available well before
>>> > cordova.js finished loading.  So, I would either check for
>>> > device.cordova or register for deviceready and wait for it to fire.
>>> >
>>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com> wrote:
>>> >> +1
>>> >>
>>> >> This isn't a platform issue but rather a developer issue
>>> >>
>>> >> Sent from my iPhone
>>> >>
>>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>>> >>
>>> >>> Presumably the developer knows the url of their own server, so
>>> >>> wouldn't it be easier to just test for that in window.location?
>>> >>>
>>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
>>> wrote:
>>> >>>> So the bigger question then is how to handle the differences ...
>>> >>>>
>>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>>> >>>>> It is to run a single codebase (or as close to it as possible minus
>>> the
>>> >>>>> differences in cordova.js) across web and cordova apps.
>>> >>>>>
>>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>> >>>>>
>>> >>>>>> Can we back up and discuss the goal?
>>> >>>>>>
>>> >>>>>> Is it to use the same code on the server + inside an app ( that is
>>> >>>>>> packaged for multiple platforms ) ?
>>> >>>>>> OR
>>> >>>>>> Is it to load an app on multiple devices all served by the same
>>> server?
>>> >>>>>>
>>> >>>>>>
>>> >>>>>>
>>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>> >>>>>>> Its yucky and may break in a future platform version, but since
>>> each
>>> >>>>>>> platform requires its own cordova.js -- then each platform could
>>> define
>>> >>>>>>> its
>>> >>>>>>> own cordova.isWebView?
>>> >>>>>>>
>>> >>>>>>> wp7 is x-wmapp
>>> >>>>>>> iOS is file://
>>> >>>>>>> BB is http://localhost
>>> >>>>>>> Android is ?
>>> >>>>>>>
>>> >>>>>>>
>>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com>
>>> wrote:
>>> >>>>>>>
>>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
>>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
>>> >>>>>>>>
>>> >>>>>>>> So file:// will not work
>>> >>>>>>>>
>>> >>>>>>>> There are probably numerous other approches ...
>>> >>>>>>>> deviceready will/should never fire, but that is difficult to test
>>> for,
>>> >>>>>>>> because it could just be taking a real long time.
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> I see many issues with this though:
>>> >>>>>>>> - each platform still requires it's own cordova.js, so this would
>>> only
>>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up for this
>>> >>>>>>>> will solve the bigger problem.
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com>
>>> wrote:
>>> >>>>>>>>> document.location starts with http://localhost OR starts with
>>> file://
>>> >>>>>>>> then?
>>> >>>>>>>>> ;)
>>> >>>>>>>>> In any case, any js variable that we could set can be overridden
>>> of
>>> >>>>>>>> course.
>>> >>>>>>>>>
>>> >>>>>>>>>
>>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
>>> wrote:
>>> >>>>>>>>>
>>> >>>>>>>>>> I think in BB WEbWorks you get
>>> http://localhost/somethingsoemthing
>>> >>>>>>>>>>
>>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>> >>>>>>>>>>
>>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>>> document.location
>>> >>>>>>>> starts
>>> >>>>>>>>>>> with file:// ?
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> --
>>> >>>>>>>> @purplecabbage
>>> >>>>>>>> risingj.com
>>> >>>>>>
>>> >>>>>>
>>> >>>>>>
>>> >>>>>> --
>>> >>>>>> @purplecabbage
>>> >>>>>> risingj.com
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> --
>>> >>>> @purplecabbage
>>> >>>> risingj.com
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> @purplecabbage
>>> >>> risingj.com
>>>

Re: Determining if "you're in cordova"

Posted by Simon MacDonald <si...@gmail.com>.
Yup, window.open(url, "_blank") will load the InAppBrowser which is
basically a renamed ChildBrowser that actually follows a spec for
events.
Simon Mac Donald
http://hi.im/simonmacdonald


On Mon, Dec 3, 2012 at 2:40 PM, Max Ogden <ma...@maxogden.com> wrote:
> In Gather we have a login page that uses childbrowser popup windows for
> oauth if its running in phonegap or popup windows in javascript if in
> browser. It would be nice childbrowser polyfilled target="_blank" (which I
> understand is happening in the future) but as for now the heuristics for
> detecting which strategy to use boil down to sniffing window.location.href
> which isn't ideal:
>
> - if I open my apps index.html in chrome it will have a file:// url but
> wont be in phonegap.
> - if I hardcode a domain into my app so that it knows if it is running from
> a server its another thing to remember to update every time the domain name
> changes
> - I already do conditional loading of stylesheets and JS based on user
> agent. I think it would be super useful if there was a user agent
> equivalent for cordova so the code could decide what to do based on
> environment and not guesses based on href
>
>
> On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:
>
>> Eh Fil, is this so they can detect if they have device apis ultimately?
>>
>> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <cu...@gmail.com>
>> wrote:
>> > I think the answer depends upon when the app checks to see if it is
>> > running in cordova webview.  If it is loading a remote url with remote
>> > cordova.js, then the native side will become available well before
>> > cordova.js finished loading.  So, I would either check for
>> > device.cordova or register for deviceready and wait for it to fire.
>> >
>> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com> wrote:
>> >> +1
>> >>
>> >> This isn't a platform issue but rather a developer issue
>> >>
>> >> Sent from my iPhone
>> >>
>> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>> >>
>> >>> Presumably the developer knows the url of their own server, so
>> >>> wouldn't it be easier to just test for that in window.location?
>> >>>
>> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
>> wrote:
>> >>>> So the bigger question then is how to handle the differences ...
>> >>>>
>> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>> >>>>> It is to run a single codebase (or as close to it as possible minus
>> the
>> >>>>> differences in cordova.js) across web and cordova apps.
>> >>>>>
>> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>> >>>>>
>> >>>>>> Can we back up and discuss the goal?
>> >>>>>>
>> >>>>>> Is it to use the same code on the server + inside an app ( that is
>> >>>>>> packaged for multiple platforms ) ?
>> >>>>>> OR
>> >>>>>> Is it to load an app on multiple devices all served by the same
>> server?
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>> >>>>>>> Its yucky and may break in a future platform version, but since
>> each
>> >>>>>>> platform requires its own cordova.js -- then each platform could
>> define
>> >>>>>>> its
>> >>>>>>> own cordova.isWebView?
>> >>>>>>>
>> >>>>>>> wp7 is x-wmapp
>> >>>>>>> iOS is file://
>> >>>>>>> BB is http://localhost
>> >>>>>>> Android is ?
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com>
>> wrote:
>> >>>>>>>
>> >>>>>>>> WP7 app is loaded from x-wmapp1:/
>> >>>>>>>> WP8 app is loaded from x-wmapp0:/
>> >>>>>>>>
>> >>>>>>>> So file:// will not work
>> >>>>>>>>
>> >>>>>>>> There are probably numerous other approches ...
>> >>>>>>>> deviceready will/should never fire, but that is difficult to test
>> for,
>> >>>>>>>> because it could just be taking a real long time.
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> I see many issues with this though:
>> >>>>>>>> - each platform still requires it's own cordova.js, so this would
>> only
>> >>>>>>>> work with 1 platform + a webserver, so no idea we come up for this
>> >>>>>>>> will solve the bigger problem.
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com>
>> wrote:
>> >>>>>>>>> document.location starts with http://localhost OR starts with
>> file://
>> >>>>>>>> then?
>> >>>>>>>>> ;)
>> >>>>>>>>> In any case, any js variable that we could set can be overridden
>> of
>> >>>>>>>> course.
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
>> wrote:
>> >>>>>>>>>
>> >>>>>>>>>> I think in BB WEbWorks you get
>> http://localhost/somethingsoemthing
>> >>>>>>>>>>
>> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>> >>>>>>>>>>
>> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
>> document.location
>> >>>>>>>> starts
>> >>>>>>>>>>> with file:// ?
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> --
>> >>>>>>>> @purplecabbage
>> >>>>>>>> risingj.com
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> --
>> >>>>>> @purplecabbage
>> >>>>>> risingj.com
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> @purplecabbage
>> >>>> risingj.com
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> @purplecabbage
>> >>> risingj.com
>>

Re: Determining if "you're in cordova"

Posted by Brion Vibber <br...@pobox.com>.
On Mon, Dec 3, 2012 at 11:40 AM, Max Ogden <ma...@maxogden.com> wrote:

> - I already do conditional loading of stylesheets and JS based on user
> agent. I think it would be super useful if there was a user agent
> equivalent for cordova so the code could decide what to do based on
> environment and not guesses based on href
>

We also like to tweak the user-agent with our application's name and
version to help track usage of the Wikipedia app's web API usage... a
standard way to append/prepend things into the User-Agent would be nicer
than hacking the AppDelegate / DroidGapApplication class every time we
update the project.

Having 'Cordova' in there by default would be... very handy.

-- brion

Re: Determining if "you're in cordova"

Posted by Max Ogden <ma...@maxogden.com>.
In Gather we have a login page that uses childbrowser popup windows for
oauth if its running in phonegap or popup windows in javascript if in
browser. It would be nice childbrowser polyfilled target="_blank" (which I
understand is happening in the future) but as for now the heuristics for
detecting which strategy to use boil down to sniffing window.location.href
which isn't ideal:

- if I open my apps index.html in chrome it will have a file:// url but
wont be in phonegap.
- if I hardcode a domain into my app so that it knows if it is running from
a server its another thing to remember to update every time the domain name
changes
- I already do conditional loading of stylesheets and JS based on user
agent. I think it would be super useful if there was a user agent
equivalent for cordova so the code could decide what to do based on
environment and not guesses based on href


On Sun, Dec 2, 2012 at 11:30 AM, Brian LeRoux <b...@brian.io> wrote:

> Eh Fil, is this so they can detect if they have device apis ultimately?
>
> On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <cu...@gmail.com>
> wrote:
> > I think the answer depends upon when the app checks to see if it is
> > running in cordova webview.  If it is loading a remote url with remote
> > cordova.js, then the native side will become available well before
> > cordova.js finished loading.  So, I would either check for
> > device.cordova or register for deviceready and wait for it to fire.
> >
> > On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com> wrote:
> >> +1
> >>
> >> This isn't a platform issue but rather a developer issue
> >>
> >> Sent from my iPhone
> >>
> >> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
> >>
> >>> Presumably the developer knows the url of their own server, so
> >>> wouldn't it be easier to just test for that in window.location?
> >>>
> >>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com>
> wrote:
> >>>> So the bigger question then is how to handle the differences ...
> >>>>
> >>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
> >>>>> It is to run a single codebase (or as close to it as possible minus
> the
> >>>>> differences in cordova.js) across web and cordova apps.
> >>>>>
> >>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
> >>>>>
> >>>>>> Can we back up and discuss the goal?
> >>>>>>
> >>>>>> Is it to use the same code on the server + inside an app ( that is
> >>>>>> packaged for multiple platforms ) ?
> >>>>>> OR
> >>>>>> Is it to load an app on multiple devices all served by the same
> server?
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
> >>>>>>> Its yucky and may break in a future platform version, but since
> each
> >>>>>>> platform requires its own cordova.js -- then each platform could
> define
> >>>>>>> its
> >>>>>>> own cordova.isWebView?
> >>>>>>>
> >>>>>>> wp7 is x-wmapp
> >>>>>>> iOS is file://
> >>>>>>> BB is http://localhost
> >>>>>>> Android is ?
> >>>>>>>
> >>>>>>>
> >>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com>
> wrote:
> >>>>>>>
> >>>>>>>> WP7 app is loaded from x-wmapp1:/
> >>>>>>>> WP8 app is loaded from x-wmapp0:/
> >>>>>>>>
> >>>>>>>> So file:// will not work
> >>>>>>>>
> >>>>>>>> There are probably numerous other approches ...
> >>>>>>>> deviceready will/should never fire, but that is difficult to test
> for,
> >>>>>>>> because it could just be taking a real long time.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> I see many issues with this though:
> >>>>>>>> - each platform still requires it's own cordova.js, so this would
> only
> >>>>>>>> work with 1 platform + a webserver, so no idea we come up for this
> >>>>>>>> will solve the bigger problem.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com>
> wrote:
> >>>>>>>>> document.location starts with http://localhost OR starts with
> file://
> >>>>>>>> then?
> >>>>>>>>> ;)
> >>>>>>>>> In any case, any js variable that we could set can be overridden
> of
> >>>>>>>> course.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com>
> wrote:
> >>>>>>>>>
> >>>>>>>>>> I think in BB WEbWorks you get
> http://localhost/somethingsoemthing
> >>>>>>>>>>
> >>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>>> "how do we know if we're in cordova or not?" -->
> document.location
> >>>>>>>> starts
> >>>>>>>>>>> with file:// ?
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> @purplecabbage
> >>>>>>>> risingj.com
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> @purplecabbage
> >>>>>> risingj.com
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> @purplecabbage
> >>>> risingj.com
> >>>
> >>>
> >>>
> >>> --
> >>> @purplecabbage
> >>> risingj.com
>

Re: Determining if "you're in cordova"

Posted by Brian LeRoux <b...@brian.io>.
Eh Fil, is this so they can detect if they have device apis ultimately?

On Sat, Dec 1, 2012 at 1:31 AM, Bryce Curtis <cu...@gmail.com> wrote:
> I think the answer depends upon when the app checks to see if it is
> running in cordova webview.  If it is loading a remote url with remote
> cordova.js, then the native side will become available well before
> cordova.js finished loading.  So, I would either check for
> device.cordova or register for deviceready and wait for it to fire.
>
> On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com> wrote:
>> +1
>>
>> This isn't a platform issue but rather a developer issue
>>
>> Sent from my iPhone
>>
>> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>>
>>> Presumably the developer knows the url of their own server, so
>>> wouldn't it be easier to just test for that in window.location?
>>>
>>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com> wrote:
>>>> So the bigger question then is how to handle the differences ...
>>>>
>>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>> It is to run a single codebase (or as close to it as possible minus the
>>>>> differences in cordova.js) across web and cordova apps.
>>>>>
>>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>>>>
>>>>>> Can we back up and discuss the goal?
>>>>>>
>>>>>> Is it to use the same code on the server + inside an app ( that is
>>>>>> packaged for multiple platforms ) ?
>>>>>> OR
>>>>>> Is it to load an app on multiple devices all served by the same server?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>>>>>> Its yucky and may break in a future platform version, but since each
>>>>>>> platform requires its own cordova.js -- then each platform could define
>>>>>>> its
>>>>>>> own cordova.isWebView?
>>>>>>>
>>>>>>> wp7 is x-wmapp
>>>>>>> iOS is file://
>>>>>>> BB is http://localhost
>>>>>>> Android is ?
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>>>>>>
>>>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>>>>
>>>>>>>> So file:// will not work
>>>>>>>>
>>>>>>>> There are probably numerous other approches ...
>>>>>>>> deviceready will/should never fire, but that is difficult to test for,
>>>>>>>> because it could just be taking a real long time.
>>>>>>>>
>>>>>>>>
>>>>>>>> I see many issues with this though:
>>>>>>>> - each platform still requires it's own cordova.js, so this would only
>>>>>>>> work with 1 platform + a webserver, so no idea we come up for this
>>>>>>>> will solve the bigger problem.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>>>>>>>> document.location starts with http://localhost OR starts with file://
>>>>>>>> then?
>>>>>>>>> ;)
>>>>>>>>> In any case, any js variable that we could set can be overridden of
>>>>>>>> course.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>>>>>>
>>>>>>>>>> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>>>>>>>>>
>>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> "how do we know if we're in cordova or not?" --> document.location
>>>>>>>> starts
>>>>>>>>>>> with file:// ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> @purplecabbage
>>>>>>>> risingj.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> @purplecabbage
>>>>>> risingj.com
>>>>
>>>>
>>>>
>>>> --
>>>> @purplecabbage
>>>> risingj.com
>>>
>>>
>>>
>>> --
>>> @purplecabbage
>>> risingj.com

Re: Determining if "you're in cordova"

Posted by Bryce Curtis <cu...@gmail.com>.
I think the answer depends upon when the app checks to see if it is
running in cordova webview.  If it is loading a remote url with remote
cordova.js, then the native side will become available well before
cordova.js finished loading.  So, I would either check for
device.cordova or register for deviceready and wait for it to fire.

On Fri, Nov 30, 2012 at 5:53 PM, Gord Tanner <gt...@gmail.com> wrote:
> +1
>
> This isn't a platform issue but rather a developer issue
>
> Sent from my iPhone
>
> On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:
>
>> Presumably the developer knows the url of their own server, so
>> wouldn't it be easier to just test for that in window.location?
>>
>> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com> wrote:
>>> So the bigger question then is how to handle the differences ...
>>>
>>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>>>> It is to run a single codebase (or as close to it as possible minus the
>>>> differences in cordova.js) across web and cordova apps.
>>>>
>>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>>>
>>>>> Can we back up and discuss the goal?
>>>>>
>>>>> Is it to use the same code on the server + inside an app ( that is
>>>>> packaged for multiple platforms ) ?
>>>>> OR
>>>>> Is it to load an app on multiple devices all served by the same server?
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>>>>> Its yucky and may break in a future platform version, but since each
>>>>>> platform requires its own cordova.js -- then each platform could define
>>>>>> its
>>>>>> own cordova.isWebView?
>>>>>>
>>>>>> wp7 is x-wmapp
>>>>>> iOS is file://
>>>>>> BB is http://localhost
>>>>>> Android is ?
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>>>>>
>>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>>>
>>>>>>> So file:// will not work
>>>>>>>
>>>>>>> There are probably numerous other approches ...
>>>>>>> deviceready will/should never fire, but that is difficult to test for,
>>>>>>> because it could just be taking a real long time.
>>>>>>>
>>>>>>>
>>>>>>> I see many issues with this though:
>>>>>>> - each platform still requires it's own cordova.js, so this would only
>>>>>>> work with 1 platform + a webserver, so no idea we come up for this
>>>>>>> will solve the bigger problem.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>>>>>>> document.location starts with http://localhost OR starts with file://
>>>>>>> then?
>>>>>>>> ;)
>>>>>>>> In any case, any js variable that we could set can be overridden of
>>>>>>> course.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>>>>>
>>>>>>>>> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>>>>>>>>
>>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> "how do we know if we're in cordova or not?" --> document.location
>>>>>>> starts
>>>>>>>>>> with file:// ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> @purplecabbage
>>>>>>> risingj.com
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> @purplecabbage
>>>>> risingj.com
>>>
>>>
>>>
>>> --
>>> @purplecabbage
>>> risingj.com
>>
>>
>>
>> --
>> @purplecabbage
>> risingj.com

Re: Determining if "you're in cordova"

Posted by Gord Tanner <gt...@gmail.com>.
+1

This isn't a platform issue but rather a developer issue

Sent from my iPhone

On 2012-11-30, at 7:11 PM, Jesse <pu...@gmail.com> wrote:

> Presumably the developer knows the url of their own server, so
> wouldn't it be easier to just test for that in window.location?
> 
> On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com> wrote:
>> So the bigger question then is how to handle the differences ...
>> 
>> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>>> It is to run a single codebase (or as close to it as possible minus the
>>> differences in cordova.js) across web and cordova apps.
>>> 
>>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>> 
>>>> Can we back up and discuss the goal?
>>>> 
>>>> Is it to use the same code on the server + inside an app ( that is
>>>> packaged for multiple platforms ) ?
>>>> OR
>>>> Is it to load an app on multiple devices all served by the same server?
>>>> 
>>>> 
>>>> 
>>>> On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>>>> Its yucky and may break in a future platform version, but since each
>>>>> platform requires its own cordova.js -- then each platform could define
>>>>> its
>>>>> own cordova.isWebView?
>>>>> 
>>>>> wp7 is x-wmapp
>>>>> iOS is file://
>>>>> BB is http://localhost
>>>>> Android is ?
>>>>> 
>>>>> 
>>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>>>> 
>>>>>> WP7 app is loaded from x-wmapp1:/
>>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>> 
>>>>>> So file:// will not work
>>>>>> 
>>>>>> There are probably numerous other approches ...
>>>>>> deviceready will/should never fire, but that is difficult to test for,
>>>>>> because it could just be taking a real long time.
>>>>>> 
>>>>>> 
>>>>>> I see many issues with this though:
>>>>>> - each platform still requires it's own cordova.js, so this would only
>>>>>> work with 1 platform + a webserver, so no idea we come up for this
>>>>>> will solve the bigger problem.
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>>>>>> document.location starts with http://localhost OR starts with file://
>>>>>> then?
>>>>>>> ;)
>>>>>>> In any case, any js variable that we could set can be overridden of
>>>>>> course.
>>>>>>> 
>>>>>>> 
>>>>>>> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>>>> 
>>>>>>>> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>>>>>>> 
>>>>>>>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>>>>>> 
>>>>>>>>> "how do we know if we're in cordova or not?" --> document.location
>>>>>> starts
>>>>>>>>> with file:// ?
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> --
>>>>>> @purplecabbage
>>>>>> risingj.com
>>>> 
>>>> 
>>>> 
>>>> --
>>>> @purplecabbage
>>>> risingj.com
>> 
>> 
>> 
>> --
>> @purplecabbage
>> risingj.com
> 
> 
> 
> -- 
> @purplecabbage
> risingj.com

Re: Determining if "you're in cordova"

Posted by Jesse <pu...@gmail.com>.
Presumably the developer knows the url of their own server, so
wouldn't it be easier to just test for that in window.location?

On Fri, Nov 30, 2012 at 4:07 PM, Jesse <pu...@gmail.com> wrote:
> So the bigger question then is how to handle the differences ...
>
> On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
>> It is to run a single codebase (or as close to it as possible minus the
>> differences in cordova.js) across web and cordova apps.
>>
>> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>>
>>>Can we back up and discuss the goal?
>>>
>>>Is it to use the same code on the server + inside an app ( that is
>>>packaged for multiple platforms ) ?
>>>OR
>>>Is it to load an app on multiple devices all served by the same server?
>>>
>>>
>>>
>>>On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>>> Its yucky and may break in a future platform version, but since each
>>>> platform requires its own cordova.js -- then each platform could define
>>>>its
>>>> own cordova.isWebView?
>>>>
>>>> wp7 is x-wmapp
>>>> iOS is file://
>>>> BB is http://localhost
>>>> Android is ?
>>>>
>>>>
>>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>>>
>>>>> WP7 app is loaded from x-wmapp1:/
>>>>> WP8 app is loaded from x-wmapp0:/
>>>>>
>>>>> So file:// will not work
>>>>>
>>>>> There are probably numerous other approches ...
>>>>> deviceready will/should never fire, but that is difficult to test for,
>>>>> because it could just be taking a real long time.
>>>>>
>>>>>
>>>>> I see many issues with this though:
>>>>> - each platform still requires it's own cordova.js, so this would only
>>>>> work with 1 platform + a webserver, so no idea we come up for this
>>>>> will solve the bigger problem.
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>>>> > document.location starts with http://localhost OR starts with file://
>>>>> then?
>>>>> > ;)
>>>>> > In any case, any js variable that we could set can be overridden of
>>>>> course.
>>>>> >
>>>>> >
>>>>> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>>>> >
>>>>> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>>>> >>
>>>>> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>>> >>
>>>>> >> >"how do we know if we're in cordova or not?" --> document.location
>>>>> starts
>>>>> >> >with file:// ?
>>>>> >>
>>>>> >>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> @purplecabbage
>>>>> risingj.com
>>>>>
>>>
>>>
>>>
>>>--
>>>@purplecabbage
>>>risingj.com
>>
>
>
>
> --
> @purplecabbage
> risingj.com



-- 
@purplecabbage
risingj.com

Re: Determining if "you're in cordova"

Posted by Jesse <pu...@gmail.com>.
So the bigger question then is how to handle the differences ...

On Fri, Nov 30, 2012 at 4:04 PM, Filip Maj <fi...@adobe.com> wrote:
> It is to run a single codebase (or as close to it as possible minus the
> differences in cordova.js) across web and cordova apps.
>
> On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:
>
>>Can we back up and discuss the goal?
>>
>>Is it to use the same code on the server + inside an app ( that is
>>packaged for multiple platforms ) ?
>>OR
>>Is it to load an app on multiple devices all served by the same server?
>>
>>
>>
>>On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>>> Its yucky and may break in a future platform version, but since each
>>> platform requires its own cordova.js -- then each platform could define
>>>its
>>> own cordova.isWebView?
>>>
>>> wp7 is x-wmapp
>>> iOS is file://
>>> BB is http://localhost
>>> Android is ?
>>>
>>>
>>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>>
>>>> WP7 app is loaded from x-wmapp1:/
>>>> WP8 app is loaded from x-wmapp0:/
>>>>
>>>> So file:// will not work
>>>>
>>>> There are probably numerous other approches ...
>>>> deviceready will/should never fire, but that is difficult to test for,
>>>> because it could just be taking a real long time.
>>>>
>>>>
>>>> I see many issues with this though:
>>>> - each platform still requires it's own cordova.js, so this would only
>>>> work with 1 platform + a webserver, so no idea we come up for this
>>>> will solve the bigger problem.
>>>>
>>>>
>>>>
>>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>>> > document.location starts with http://localhost OR starts with file://
>>>> then?
>>>> > ;)
>>>> > In any case, any js variable that we could set can be overridden of
>>>> course.
>>>> >
>>>> >
>>>> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>>> >
>>>> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>>> >>
>>>> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>>> >>
>>>> >> >"how do we know if we're in cordova or not?" --> document.location
>>>> starts
>>>> >> >with file:// ?
>>>> >>
>>>> >>
>>>>
>>>>
>>>>
>>>> --
>>>> @purplecabbage
>>>> risingj.com
>>>>
>>
>>
>>
>>--
>>@purplecabbage
>>risingj.com
>



-- 
@purplecabbage
risingj.com

Re: Determining if "you're in cordova"

Posted by Filip Maj <fi...@adobe.com>.
It is to run a single codebase (or as close to it as possible minus the
differences in cordova.js) across web and cordova apps.

On 11/30/12 4:02 PM, "Jesse" <pu...@gmail.com> wrote:

>Can we back up and discuss the goal?
>
>Is it to use the same code on the server + inside an app ( that is
>packaged for multiple platforms ) ?
>OR
>Is it to load an app on multiple devices all served by the same server?
>
>
>
>On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
>> Its yucky and may break in a future platform version, but since each
>> platform requires its own cordova.js -- then each platform could define
>>its
>> own cordova.isWebView?
>>
>> wp7 is x-wmapp
>> iOS is file://
>> BB is http://localhost
>> Android is ?
>>
>>
>> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>>
>>> WP7 app is loaded from x-wmapp1:/
>>> WP8 app is loaded from x-wmapp0:/
>>>
>>> So file:// will not work
>>>
>>> There are probably numerous other approches ...
>>> deviceready will/should never fire, but that is difficult to test for,
>>> because it could just be taking a real long time.
>>>
>>>
>>> I see many issues with this though:
>>> - each platform still requires it's own cordova.js, so this would only
>>> work with 1 platform + a webserver, so no idea we come up for this
>>> will solve the bigger problem.
>>>
>>>
>>>
>>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>>> > document.location starts with http://localhost OR starts with file://
>>> then?
>>> > ;)
>>> > In any case, any js variable that we could set can be overridden of
>>> course.
>>> >
>>> >
>>> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>>> >
>>> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>> >>
>>> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>> >>
>>> >> >"how do we know if we're in cordova or not?" --> document.location
>>> starts
>>> >> >with file:// ?
>>> >>
>>> >>
>>>
>>>
>>>
>>> --
>>> @purplecabbage
>>> risingj.com
>>>
>
>
>
>-- 
>@purplecabbage
>risingj.com


Re: Determining if "you're in cordova"

Posted by Jesse <pu...@gmail.com>.
Can we back up and discuss the goal?

Is it to use the same code on the server + inside an app ( that is
packaged for multiple platforms ) ?
OR
Is it to load an app on multiple devices all served by the same server?



On Fri, Nov 30, 2012 at 3:56 PM, Shazron <sh...@gmail.com> wrote:
> Its yucky and may break in a future platform version, but since each
> platform requires its own cordova.js -- then each platform could define its
> own cordova.isWebView?
>
> wp7 is x-wmapp
> iOS is file://
> BB is http://localhost
> Android is ?
>
>
> On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>
>> WP7 app is loaded from x-wmapp1:/
>> WP8 app is loaded from x-wmapp0:/
>>
>> So file:// will not work
>>
>> There are probably numerous other approches ...
>> deviceready will/should never fire, but that is difficult to test for,
>> because it could just be taking a real long time.
>>
>>
>> I see many issues with this though:
>> - each platform still requires it's own cordova.js, so this would only
>> work with 1 platform + a webserver, so no idea we come up for this
>> will solve the bigger problem.
>>
>>
>>
>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>> > document.location starts with http://localhost OR starts with file://
>> then?
>> > ;)
>> > In any case, any js variable that we could set can be overridden of
>> course.
>> >
>> >
>> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>> >
>> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>> >>
>> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>> >>
>> >> >"how do we know if we're in cordova or not?" --> document.location
>> starts
>> >> >with file:// ?
>> >>
>> >>
>>
>>
>>
>> --
>> @purplecabbage
>> risingj.com
>>



-- 
@purplecabbage
risingj.com

Re: Determining if "you're in cordova"

Posted by Filip Maj <fi...@adobe.com>.
Yeh this makes more sense.. Delegate "iswebview" to each platform
implementation.

BTW Android is file:// as well

On 11/30/12 3:56 PM, "Shazron" <sh...@gmail.com> wrote:

>Its yucky and may break in a future platform version, but since each
>platform requires its own cordova.js -- then each platform could define
>its
>own cordova.isWebView?
>
>wp7 is x-wmapp
>iOS is file://
>BB is http://localhost
>Android is ?
>
>
>On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:
>
>> WP7 app is loaded from x-wmapp1:/
>> WP8 app is loaded from x-wmapp0:/
>>
>> So file:// will not work
>>
>> There are probably numerous other approches ...
>> deviceready will/should never fire, but that is difficult to test for,
>> because it could just be taking a real long time.
>>
>>
>> I see many issues with this though:
>> - each platform still requires it's own cordova.js, so this would only
>> work with 1 platform + a webserver, so no idea we come up for this
>> will solve the bigger problem.
>>
>>
>>
>> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
>> > document.location starts with http://localhost OR starts with file://
>> then?
>> > ;)
>> > In any case, any js variable that we could set can be overridden of
>> course.
>> >
>> >
>> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>> >
>> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>> >>
>> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>> >>
>> >> >"how do we know if we're in cordova or not?" --> document.location
>> starts
>> >> >with file:// ?
>> >>
>> >>
>>
>>
>>
>> --
>> @purplecabbage
>> risingj.com
>>


Re: Determining if "you're in cordova"

Posted by Shazron <sh...@gmail.com>.
Its yucky and may break in a future platform version, but since each
platform requires its own cordova.js -- then each platform could define its
own cordova.isWebView?

wp7 is x-wmapp
iOS is file://
BB is http://localhost
Android is ?


On Fri, Nov 30, 2012 at 3:49 PM, Jesse <pu...@gmail.com> wrote:

> WP7 app is loaded from x-wmapp1:/
> WP8 app is loaded from x-wmapp0:/
>
> So file:// will not work
>
> There are probably numerous other approches ...
> deviceready will/should never fire, but that is difficult to test for,
> because it could just be taking a real long time.
>
>
> I see many issues with this though:
> - each platform still requires it's own cordova.js, so this would only
> work with 1 platform + a webserver, so no idea we come up for this
> will solve the bigger problem.
>
>
>
> On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
> > document.location starts with http://localhost OR starts with file://
> then?
> > ;)
> > In any case, any js variable that we could set can be overridden of
> course.
> >
> >
> > On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
> >
> >> I think in BB WEbWorks you get http://localhost/somethingsoemthing
> >>
> >> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
> >>
> >> >"how do we know if we're in cordova or not?" --> document.location
> starts
> >> >with file:// ?
> >>
> >>
>
>
>
> --
> @purplecabbage
> risingj.com
>

Re: Determining if "you're in cordova"

Posted by Jesse <pu...@gmail.com>.
WP7 app is loaded from x-wmapp1:/
WP8 app is loaded from x-wmapp0:/

So file:// will not work

There are probably numerous other approches ...
deviceready will/should never fire, but that is difficult to test for,
because it could just be taking a real long time.


I see many issues with this though:
- each platform still requires it's own cordova.js, so this would only
work with 1 platform + a webserver, so no idea we come up for this
will solve the bigger problem.



On Fri, Nov 30, 2012 at 3:46 PM, Shazron <sh...@gmail.com> wrote:
> document.location starts with http://localhost OR starts with file:// then?
> ;)
> In any case, any js variable that we could set can be overridden of course.
>
>
> On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:
>
>> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>>
>> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>>
>> >"how do we know if we're in cordova or not?" --> document.location starts
>> >with file:// ?
>>
>>



-- 
@purplecabbage
risingj.com

Re: Determining if "you're in cordova"

Posted by Shazron <sh...@gmail.com>.
document.location starts with http://localhost OR starts with file:// then?
;)
In any case, any js variable that we could set can be overridden of course.


On Fri, Nov 30, 2012 at 3:38 PM, Filip Maj <fi...@adobe.com> wrote:

> I think in BB WEbWorks you get http://localhost/somethingsoemthing
>
> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
>
> >"how do we know if we're in cordova or not?" --> document.location starts
> >with file:// ?
>
>

Re: Determining if "you're in cordova"

Posted by Gord Tanner <gt...@gmail.com>.
My gut told me _nativeReady but I don't think that is cross platform.

I think we should work harder at making Cordova.js be a noop when in a standard browser which shouldn't be to hard.

Sent from my iPhone

On 2012-11-30, at 6:38 PM, Filip Maj <fi...@adobe.com> wrote:

> I think in BB WEbWorks you get http://localhost/somethingsoemthing
> 
> On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:
> 
>> "how do we know if we're in cordova or not?" --> document.location starts
>> with file:// ?
> 

Re: Determining if "you're in cordova"

Posted by Filip Maj <fi...@adobe.com>.
I think in BB WEbWorks you get http://localhost/somethingsoemthing

On 11/30/12 3:35 PM, "Shazron" <sh...@gmail.com> wrote:

>"how do we know if we're in cordova or not?" --> document.location starts
>with file:// ?


Re: Determining if "you're in cordova"

Posted by Shazron <sh...@gmail.com>.
"how do we know if we're in cordova or not?" --> document.location starts
with file:// ?