PDA

View Full Version : Using the PhoneGap InAppBrowser plugin



barrymavin
2017-08-28, 23:59
In mobile Apps (i.e. the facebook App) it is common to click a link and overlay a web page over the App. You will notice a "< Back" button at the top of the screen (or in the case of Android a x). Touching this returns you back to the App.

In PhoneGap/Cordova this functionality is made available using the InAppBrowser plugin.

So for example if you want to "View an order" in your App you can generate the order using a server-side .rsp page like this in your JavaScript delegate code.


var view_url;
if (Lianja.isPhoneGap())
{
view_url = Lianja.App.getFullPathUrl( "apps/" + Lianja.App.name + "/view_order.rsp" );
} else {
view_url = "view_order.rsp";
}
window.open(view_url, "_blank", "location=yes")

In Lianja 4.0 desktop Apps you can invoke this in a WebView section which will replace the WebView contents with the new content. A "<Back" button will also be displayed on the top left of the WebView, which when clicked will go back to the previous contents.

In Web Apps a new Tab will be displayed containing the new content.

When developing PhoneGap Apps you can use the Chrome Developer Tools console for testing.