Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Archive for November 2012

InAppBrowser (based on ChildBrowser) in Cordova 2.3.0

The inclusion of the InAppBrowser in iOS and Android will be new for Cordova 2.3.0. You can play with the InAppBrowser today if you download the latest code and help us test.

The InAppBrowser is a built-in web browser for your app that has an API that follows web standards. It follows the window.open API, except for a new window target that we introduced: “_system“. Read our simple specification.

Does this mean the ChildBrowser is going away? Not really. These two plugins can co-exist, and ChildBrowser has added features that are not present in the InAppBrowser, particularly events. [UPDATE: see below]InAppBrowser also has no dependencies on a .xib or external images, so it is easy to integrate for upgrades.

What’s also new with the InAppBrowser implementation for iOS is, the white-list is not applied application wide anymore, the white-list will only apply for the main Cordova UIWebView only. Now you can load non-white-listed URLs into the InAppBrowser and the ChildBrowser.

There are several enhancements for plugins related to this new white-list exception functionality as well – please see issue CB-1889. The enhancements should land before the final 2.3.0 is released.

Please help us test by downloading the latest code or RC and giving this new feature a spin!

[Update Nov 28 2012]: The InAppBrowser on iOS has support for events now (Android in progress). You can listen to the ‘loadstart‘, ‘loadstop‘ and ‘exit‘ events. The callback function is passed an event object that has two properties: type, and url. You will need to grab the latest code and javascript (create a new project).

Example usage:

var ref = window.open('http://google.com', '_blank');
ref.addEventListener('loadstart', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('loadstop', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('exit', function(event) { alert(event.type); } );

// also, you can do ref.removeEventListener('loadstart', myfunc) .. etc

[Update Nov 30 2012]: Changes for InAppBrowser events for Android are in cordova-android now.

[Update Jan 7 2013]: If you have a multi-page app, and you use InAppBrowser, and you use iOS 6, you must use iframe bridge mode. More details here.

Written by shazron

November 21, 2012 at 8:06 pm

Cordova plugins? Put them in your own repo

with 19 comments

[edited: removed reference to pluginstall which is PhoneGap Build centric, to Plugman which is based on pluginstall but is Cordova centric, and more frequently updated]

Right now, there is one repo that contains the majority of plugins available for Cordova at: http://github.com/phonegap/phonegap-plugins

We don’t want to “clutter” this repo with code anymore. Authors should maintain the code in their own repos and publish them to the Cordova Plugin Registry.

Having the plugins in separate repos also enables less clutter for pull requests and bugs, with it all being in one repo it is hard to get attention for an issue since that can be buried. I know that I like to fix some of my plugins, but it’s hard with it all lumped in there with other unrelated plugin issues.

As a reminder, this is how to write a Plugin:
http://docs.cordova.io/en/edge/guide_plugin-development_index.md.html#Plugin%20Development%20Guide

For examples of plugins that conform to the Cordova Plugin spec and are plugman-able:

  1. https://github.com/phonegap-build/BarcodeScanner
  2. https://github.com/phonegap-build/ChildBrowser
  3. https://github.com/phonegap-build/GAPlugin
  4. https://github.com/shazron/TestFlightPlugin
  5. https://github.com/shazron/KeychainPlugin

I’ve already moved out the plugins that I started implementation on (iAdPlugin, KeychainPlugin, PayPalPlugin, TorchPlugin, TestFlightPlugin). I suggest that you do the same.

Written by shazron

November 7, 2012 at 11:40 pm

Posted in cordova, phonegap

Follow

Get every new post delivered to your Inbox.

Join 1,490 other followers

%d bloggers like this: