dileepbapat / gwt-phonegap

Automatically exported from code.google.com/p/gwt-phonegap
0 stars 0 forks source link

phonegap.env always equal to no #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
phonegap.env is always equal to "no" so PhoneGap.class always is instance of 
com.googlecode.gwtphonegap.client.PhoneGapBrowserImpl

(tested with GWT 2.4 et GWT PhoneGap 1.0.0)

Patch :

<define-property name="phonegap.env" values="yes, no" />
<property-provider name="phonegap.env"><![CDATA[
{
  var ua = window.navigator.userAgent.toLowerCase();
  if (ua.indexOf('android') != -1 || ua.indexOf('ipad') != -1 || ua.indexOf('iphone') != -1 || ua.indexOf('blackberry') != -1) 
    { 
      // var url = document.location.href;
      // if(url.indexOf("file://") === 0)
      // {
        return "yes";
      // }
  }
  return 'no';
}

Original issue reported on code.google.com by stbl...@gmail.com on 11 Oct 2011 at 11:48

GoogleCodeExporter commented 9 years ago
the file to be patched is PhoneGap.gwt.xml

Original comment by stbl...@gmail.com on 11 Oct 2011 at 11:56

GoogleCodeExporter commented 9 years ago
phonegap requires to loads the html file containing your app with file://, so 
phonegap env. is only true on devices. This is as intended

Original comment by kurka.da...@gmail.com on 11 Oct 2011 at 12:10

GoogleCodeExporter commented 9 years ago
In my case, a I have a webapp written in Java, with static GWT Javascript and 
dynamic RPC Servlet, my iPhone PhoneGap application don't call an embedded 
static HTML file but the remote URL of my webapp, so URL nether contains 
"file://" but "http://" or "https://".

Extract of Objective-C code :

@interface MyGwtWebappPhoneGapAppDelegate : PhoneGapDelegate {

}

@end

@implementation MyGwtWebappPhoneGapAppDelegate

// override PhoneGapDelegate.startPage() 
+ (NSString*) startPage
{
  return @"http://<myhost>/<mywebapp>/myGwtModule.html";
}
@end

(sorry for my poor english, I'am french)

Original comment by stbl...@gmail.com on 11 Oct 2011 at 1:09

GoogleCodeExporter commented 9 years ago
If this would work, it would be a very big security hole for your app (changing 
the remote html file would open the device for all sorts of attacks). This is 
why phonegap does not allow to use phonegap features if they are called from a 
remote url. In this way this would not make any sense for gwt-phonegap to patch 
this, because phonegap would`t allow us to work. 
(http://groups.google.com/group/phonegap/browse_thread/thread/806d4fd2747ba4cd/9
f2e21a942f74a21?lnk=gst&q=remote+html+file#9f2e21a942f74a21)

If you are trying to get gwt rpc working with phonegap take a look at my 
blogpost: http://blog.daniel-kurka.de/2011/01/gwt-rpc-with-phonegap.html

Original comment by kurka.da...@gmail.com on 11 Oct 2011 at 2:34

GoogleCodeExporter commented 9 years ago
Could you give a hint where phongap/cordova enforces this kind of security and 
how to disable it?

Original comment by robert.d...@gmail.com on 21 May 2012 at 10:02