cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gord Tanner <gtan...@gmail.com>
Subject Re: Determining if "you're in cordova"
Date Mon, 03 Dec 2012 23:45:31 GMT
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 <max@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 <max@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 <anis.kadri@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
>>>>> <simon.macdonald@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 <max@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 <purplecabbage@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
<fil@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" <purplecabbage@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" <shazron@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
>> 

Mime
View raw message