Archive for the ‘phonegap’ Category
What’s new in Cordova iOS 2.7.0
Mainly bug fixes, the only highlights are new features for InAppBrowser – executeScript() and insertCSS(). Download 2.7.0.
1. Script Updates
- [CB–2849] Fix bin/create when CordovaLib parent dir has a space
- [CB–2788] add ./bin/check_reqs script to iOS
- [CB–3048] Add –arc flag to create script, support arc in template.
2. FileTransfer Updates
- [CB–2537] Implement streaming downloads for FileTransfer
- [CB–2190] Allow FileTransfer uploads/downloads to continue in background
- [CB–1518] Request content length in parallel with download for gzipped content
- [CB–51] Added httpMethod for file transfer options (defaults to POST)
- [CB–2824] Remove DebugConsole plugin
- [CB–3066] Fire onNativeReady from JS, as bridge is available immediately
3. Whitelist Updates
- [CB–3032] Add whitelist support for custom schemes.
- [CB–3067] iOS 5.0 file urls are not passing whitelist due to recent changes
4. Miscellaneous
- [CB–2725] Fix www deploy issues with symlinks
- [CB–2732] Only set camera device when allowed.
- [CB–2911] Updated resolveLocalFileSystemURI.
- [CB–2587] Added plugin timing for plugins that are loaded on startup (plugin ‘onload’ attribute)
- [CB–2848] ShowSplashScreenSpinner not used
- [CB–2960] Changing the volume of a sound already playing
- [CB–3021] Can no longer import CDVPlugin.h from plugin Objective-C++ code
- [CB–2698] Fix load detection when pages have redirects.
5. Camera EXIF Updates
- [CB–2902] re-added long/short tags to template dict, fixed subExifIFD offset
- [CB–2896] Multipart exif tags are not written correctly
- [CB–2790] Removed old splice code, replaced with JpegHeaderWriter api calls
- [CB–3039] iOS Exif date length mismtach
- [CB–3052] iOS Exif SubIFD offsets incorrect
6. InAppBrowser Updates
- [CB–3069] Fix InAppBrowser load events (for non-redirecting pages)
- [CB–3295] Send InAppBrowser loadstart events when redirects occur
- [CB–2653] Add InAppBrowser.executeScript() / InAppBrowser.insertCSS API (iOS)
- InAppBrowser: Don’t inject iframe bridge until necessary
- Fix NPE in InAppBrowser’s error callback
Cordova/PhoneGap and the new Apple App Store Requirements
Beginning May 1st 2013, apps submitted to the Apple App Store…
2. will no longer accept new apps or app updates that access UDIDs
Cordova/PhoneGap fulfills requirement (1) since version 2.5.0 and fulfills requirement (2) since version 1.7.0.
But what if my Cordova/PhoneGap app, which I am unwilling to upgrade, needs to be updated and submitted to the App Store?
You will have to manually update and patch your code. It’s not going to be an easy task, and I should warn you that upgrading will be easier. The main changes are to handle the iPhone 5 sized splashscreen, and the code to handle that is only in Cordova/PhoneGap 2.5.0. You can include the iPhone 5 sized asset and this will trigger the app to be the right size, but because of our splashscreen support it needs to match iOS showing the splashscreen after that splashscreen disappears. See our SplashScreen API for more details.
To be doubly sure – select your project icon in the Project Navigator in Xcode, then select the Summary tab. Select your project target then review the App Icons and Launch Images sections – you’ll see if you are missing anything or whether the assets are not the right sizes (denoted by the yellow triangle icon with an exclamation point in it).
Create new PhoneGap/Cordova projects using cordova-create-gui
This is for OS X only, and does not check for project requirements yet (which may be coming with the bin/check_reqs scripts in 2.7.0). Essentially this proof of concept project is a GUI wrapper for the bin/create scripts you know and love. You could use this against the the iOS, OS X, Android and BlackBerry source (although I have only tested it for iOS and OS X projects). Think of this as Handbrake for ffmpeg.
The project routes the stderr and stdout from the script call back to your callback function, and also reports the resultcode for you to further process.
Ideally this would be a GUI for cordova-cli instead, that may come in the future. This app was also created using itself, and Cordova OS X.
Download the complete runnable project.
View and fork the source on Github.
The GUI itself won’t win any awards yet, but is workable (click to enlarge):
Cordova OS X – Resurrection
No, I didn’t use an Alien Queen embryo for this one. Dormant for so long, this has been brought up to date vis-à-vis the iOS Plugin architecture, and supports OS X 10.7 (Lion) and 10.8 (Mountain Lion). This means that if you know how to create an iOS Plugin, you can create an OS X one as well. The JavaScript to native bridge is synchronous, while the native to JavaScript bridge is asynchronous, just like iOS.
Not all core plugins are there. The only core plugins available at the moment are the Connection API, and the Device API, and the only event supported is the deviceready event.
To create a new project, follow the same command line usage as iOS. Download the source code.
The WebView used is from the system WebKit, which varies depending on your OS X version. Since it uses the system WebKit, the Web API support follows from it, and running Modernizr on a Cordova OS X project on OS X 10.8.3 there is broad support for most of the APIs out there except for indexeddb, some advanced input types, flexbox and WebGL. WebGL can be enabled in code however. See the Modernizr report below:
Future updates will add support for the rest of the Cordova APIs, whether as a JavaScript shim or as complete plugins. Interfaces to create/update the native menus, and native context (right-click) menus are also on the plate as well. Full-screen support is there already. JavaScript bindings for native objects for plugins is being considered as well.
What’s new in Cordova iOS 2.6.0
1. Config.xml <preference> changes – added KeyboardShrinksView and HideKeyboardFormAccessoryBar. UIWebViewBounce renamed to DisallowOverscroll. EnableLocation deprecated.
HideKeyboardFormAccessoryBar will hide the form accessory bar (the Next, Prev and Done buttons) when the keyboard is shown for handling input in a textbox.
KeyboardShrinksView will shrink the WebView when the keyboard comes up. The WebView shrinks instead of the viewport shrinking and the page scrollable. This applies to apps that position their elements relative to the bottom of the WebView. This is the default behaviour on Android, and makes a lot of sense when building apps as opposed to webpages.
The UIWebViewBounce preference was changed to DisallowOverscroll to be consistent with Android (thus the default value is the opposite).
The EnableLocation preference is deprecated – set the “onload” attribute of the CDVLocation plugin element instead.
2. InAppBrowser API – “loaderror” event added
You can listen for the loaderror event to be notified of any errors in loading any URLs in the InAppBrowser.
3. Notification API changes
notification.prompt feature added – allows a customizable prompt versus the JavaScript one. Also, You can also use commas for button labels for notification.confirm.
4. FileTransfer API changes
FileTransfer download allows setting of headers now. Both FileTransfer upload and download will now support Basic Auth automatically when the username and password is encoded in the URL.
5. Camera API changes
You can now select the front or back camera on Camera.getPicture(). EXIF metadata is also included in the images returned from the Camera API, see this issue. Fixed crash when camera not available.
6. Various splash-screen issues fixed
See this issue.
7. Various iframe issues fixed
8. Various FileReader issues fixed
9. Multi-part plugin result is now supported
See this and this. Basically now callbacks can receive more than one argument.
10. Plugins can be dynamically registered (outside of config.xml)
See this issue.
Other fixes are in the RELEASE NOTES.
What’s new in Cordova iOS 2.5.0

Mainly bug fixes.
1. New functionality for Plugins
Lots of enhancements, and one removal. See the Plugin Upgrade Guide. Of note, you can load plugins at startup now.
2. config.xml root element is <widget>
Shouldn’t affect your current config.xml since the config parsing doesn’t care about the root element name. There’ll be further changes to config.xml so we conform to the widget spec as we go along.
3. Better FileTransfer errors
Now you get the response body in the FileTransferError object returned.
4. Enable NSURLCache for better app performance
Set in the app template.
5. Added support for Native URIs (iOS’ assets-library:// scheme)
See CB-2213.
What’s new in Cordova iOS 2.4.0
1. Removal of JSONKit, replaced with NSJSONSerialization
Since we dropped support for iOS 4.x, this is now possible. See the Plugin Upgrade Guide.
2. Support for ArrayBuffer arguments over the exec bridge
Only for top level arguments (nothing nested). It converts the ArrayBuffer to a NSData object, and vice-versa. See CB-2189 and CB-2215.
3. The start page can be specified in config.xml
Through the content tag.
4. FileTransfer “trustAllHosts” parameter
This is now supported. Set to true to trust hosts with self-signed certificates, for example.
5. InAppBrowser enhancements, and fix
Enhancements are specified here. Basically these are the same settings as in the Project Settings, also presentation and transition styles are added. The fix for InAppBrowser is specified here. Basically, on iOS 6, when you load PDFs in the InAppBrowser, it resets the User-Agent for all UIWebViews which we rely on for our exec bridge — our fix helps work around that, with caveats.
6. Custom url-scheme handler ‘handleOpenURL’ not called on startup
It was not being called on first app launch, but has now been fixed. Resume from backgrounding has always worked.
7. FileTransfer failing for file:/// urls
Fixed. An alternative is to use xhr.
8. require.js lazy loading of cordova.js
This should work now.
9. Various deprecated methods removed
See the wiki.
10. Default splash-screen sizes 10x smaller
Shouldn’t affect you much.
11. There was an ARC issue in Contacts
See this issue.
12. Support Reading Slices of Text Files.
From Simon McDonald’s blog post regarding Cordova Android 2.4.0:
The File object now has a slice method. Suppose the file we’re reading contains the text:
“All that is gold does not glitter, not all those who wander are lost.”
Then…
- f.slice(4, 8) would result in “that”
- f.slice(9) would be “is gold does not glitter, not all those who wander are lost.”
- f.slice(-5, -1) would be “lost”
[NOTE] I want to also draw attention to cordova-cli being released with 2.4.0. More on Raymond Camden’s blog. In a nutshell, this is an abstraction for the command-line utilities that are included for the different platforms all in one easier to use interface, plus the ability to add and remove plugins.
What’s new in Cordova iOS 2.3.0
1. iOS 5.x and above support only
We are dropping iOS 4.x support and only supporting iOS 5.0 and greater, going forward.
2. Cordova.plist is changed to config.xml
The configuration Cordova.plist file has been changed to config.xml – it comes in a new format that is the same as the Android config.xml. If you are upgrading, you will need to convert your existing Cordova.plist by running the bin/cordova_plist_to_config_xml script. The 2.3.0 project itself will warn you (in the console log) if you are still using the old Cordova.plist and tell you to upgrade.
The new project settings are documented here.
An example config.xml:
<cordova>
<preference name="MySetting" value="true" />
<plugins>
<plugin name="MyPlugin" value="MyPluginClass" />
</plugins>
<access origin="*" />
</cordova>
3. InAppBrowser – includes events
More details here. In a nutshell, this has the same functionality as the ChildBrowser, and has events support as well. It supports this simplified spec. Also, the InAppBrowser does not use the app whitelist. 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
4. LocalNotification plugin event, AppDelegate override
Your project’s AppDelegate.m can add a new AppDelegate override so your plugins can receive LocalNotification events. Uncomment these lines to enable your plugin to receive the notifications in their overrides.
5. Renaming of Cordova cli commands
The new list of commands are here. Basically debug has been renamed to build, and new release, and run commands have been added. This is common across all the platforms.
6. Objective-C plugins are not white-listed anymore
With the InAppBrowser release, we restructured the whitelist to only apply to the main Cordova WebView. As a consequence, the whitelist does not apply to all connections for the app, thus connections from your plugins are not whitelisted. To whitelist your connections with the app whitelist, you will need to set the “User-Agent” header of the connection to the same user-agent as the main Cordova WebView.
You can get this by accessing the userAgent property off the main view-controller. The main view-controller (CDVViewController) also has a URLisAllowed method for you to check whether a URL will pass the whitelist. See this guide.
7. Device API changes
Minor changes as specified here. For iOS, device.platform used to return “iPhone”, “iPad” or “iPod Touch” — now it returns (correctly) “iOS”. For iOS, device.name (now deprecated for all platforms) used to return the name of the user’s device (e.g ‘Shazron’s iPhone 5′) — now it returns what device.platform used to return: ”iPhone”, “iPad” or “iPod Touch”. For all platforms, there is a new property called device.model — this returns the specific device model, e.g “iPad2,5″ (for other platforms, this returns what device.name used to return).
8. CommandDelegate overrides
The command delegate could not be overriden properly, now fixed. Please look at this issue on how to override the delegate functions, for inspection.
Check out the Release Notes for other minor changes.
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).
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.
Cordova plugins? Put them in your own repo
[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 just put a pointer in a README.md in phonegap-plugins (perhaps in the same hierarchy). What this enables is, when the time comes – package-able plugins that can be installed using plugman that are built according to the Cordova Plugin spec. This also helps for the future whenever we decide to have a npm-like registry for Cordova plugins.
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:
- https://github.com/phonegap-build/BarcodeScanner
- https://github.com/phonegap-build/ChildBrowser
- https://github.com/phonegap-build/GAPlugin
- https://github.com/shazron/TestFlightPlugin
- 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.


