Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

What’s new in Cordova iOS 2.3.0

with 40 comments

cordova_bot

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.

About these ads

Written by shazron

December 10, 2012 at 9:37 pm

40 Responses

Subscribe to comments with RSS.

  1. Thank you Shazron

    emile818

    December 11, 2012 at 7:42 am

  2. Hi Shazron – You helped me on the previous IAB blog post. I’m still having issues with opening PDFs on this Cordova app. Its a downloaded and localized website for a client that I have wrapped in Cordova to make an app they can browse on their iPads when not connected to the internet. There are lots of products, each with a few PDFs. When I start the iOS simulator and go to any page in the app and click a PDF, it opens in IAB. Any PDF on the same page will open and close perfectly. When I navigate to any other page in the app and click any PDF it does nothing. I get no error and no console log. When alerting the URL to the PDF, the URL is correct whether the IAB works or not, so I know pathing is correct. Here is my invocation code: http://pastie.org/private/wtahhkzgvevatz7rg5ctw

    This is using the latest Cordova:
    // commit 861ff3d507fd5c64ed789d8abe360690e588252e
    // File generated at :: Mon Dec 10 2012 15:38:02 GMT-0800 (PST)

    Chad

    December 12, 2012 at 5:48 am

    • Try alerting ‘window.open’ on that page where it doesn’t work, and report back.

      shazron

      December 12, 2012 at 5:52 am

      • Would that be:

        iabRef = window.open(url, “_blank”, “location=no”);
        alert(iabRef);
        iabRef.addEventListener(‘loadstart’, onLoadStart);
        iabRef.addEventListener(‘loadstart’, onLoadStop);
        iabRef.addEventListener(‘exit’, onExit);

        I tried that and its [object Object] – obviously not what you are looking for. It alerts that for working and non-working pages.

        Chad

        December 12, 2012 at 6:04 am

      • No – actually try alert(window.open) itself

        shazron

        December 12, 2012 at 6:19 am

  3. I tried al ert(window.open(url, “_blank”, “location=no”)); in both the launchURL function and higher up in the jquery code instead of calling launchURL (shown http://pastie.org/private/0ceg1dx0vck1zdtcinpfa) and on both the working pages and non working pages its still [object Object] as shown http://cl.ly/image/1i110Z1Q2m2X

    Thank you so much for your continued support.

    Chad

    December 12, 2012 at 6:30 am

  4. OK thanks.

    Working page: http://cl.ly/image/381X3B0l0l2Q

    Non-working page: http://cl.ly/image/0V0O3n042E0Q

    Chad

    December 12, 2012 at 7:01 am

    • Aha, that non-working page does not have Cordova loaded. I assume the path is correct for the cordova js?

      shazron

      December 13, 2012 at 7:13 pm

      • OK, that is correct – a copy/paste error. Still not right though.

        Working page: http://cl.ly/image/0b3w0m022c0u – alert shows up, then click OK, then PDF loads in IAB.

        Now on the non-working page, the links work when I click them, but the PDFs don’t open in IAB. http://cl.ly/image/0Q0J0y2z0W2Q – alert shows up, then click OK, then nothing happens.

        Same message, but one is within a scrolling alert. I think that is just with the wrapping html page name in the header of the alert.

        Chad

        December 13, 2012 at 7:45 pm

      • More clarification – if I have alert(window.open) in place on the non-working page, you get the alert, then click Close, then nothing happens. If I comment alert(window.open) out on the non-working page, the PDF opens, but not in IAB.

        Chad

        December 13, 2012 at 7:46 pm

      • Hi Chad, this comments section is unproductive — I suggest you file an issue at http://issues.cordova.io and assign it to me. Include a www folder with html and also sample media to illustrate the problem and for me to repro, and for others to search on. I’ll take a look there.

        shazron

        December 13, 2012 at 8:26 pm

      • I want to also make clear that I can go to either page first, and the PDFs open in IAB. Then visit the other page second, and they don’t work.

        Chad

        December 13, 2012 at 8:22 pm

  5. [...] it looks like the installation of 2.2.0 is the same as 2.1.0. However, expect exciting changes when Cordova 2.3.0 is [...]

  6. Hi Shazron, I am using PhoneGap 2.2.0 and PDF’s are a PITA to work with. Will the upcoming release enable dev’s to open PDF’s (stored in a local folder) in ChildBrowser windows with less hassle?
    …. I was taking a look at the comments and it seems some work is being done to address the solution.

    Jacques

    December 17, 2012 at 7:50 am

    • Yup. If you have a file called ‘test.pdf’ in your www folder, all you need to do is:

      window.open('test.pdf', '_blank');
      

      shazron

      December 21, 2012 at 12:09 am

      • From what I know, it is the same even in earlier version of Phonegap; Webkit opened PDFs just fine.

        Can you elaborate exactly what changed that pdf opening is easy in Cordova 2.3?

        Lakshman

        January 11, 2013 at 7:13 pm

      • the InAppBrowser.

        shazron

        January 11, 2013 at 7:22 pm

  7. still support for ios4.3?

    outlog

    December 20, 2012 at 3:15 am

    • Oops I knew I forgot something. I will amend the post.

      shazron

      December 21, 2012 at 12:04 am

  8. What do you mean by support is dropped for iOS <5.0? Does that mean Cordova will fail to do anything on iOS <5.0?

    Steven Vance

    January 8, 2013 at 12:52 am

    • Cordova will only compile under iOS 5 and greater – we are only looking forward to use iOS 5 API and up.

      shazron

      January 8, 2013 at 12:55 am

  9. [...] Informationen zu den iOS-relevanten Neuerungen finden sich im iOS-Readme, die für Android entsprechend im [...]

  10. Looks great! Thanks!

    ernestallen

    January 11, 2013 at 11:53 pm

  11. Broken for iOS?

    I’m currently using 2.2, I downloaded 2.3 but the sample project whist it builds does not run in the simulator, just says ‘tests complete’ and exits instantly. Upgraded my 2.2 project to 2.3 and it runs (i.e. doesn’t instantly exit) but the app can’t fully load, no errors in Xcode, Safari web inspector console says ‘file:///!gap_execFailed to load resource: The requested URL was not found on this server.’ several times. Perhaps the plugins have a newer format? Looked at the plugins on git but I can’t see any 2.3 specific changes.

    Shazron I need you :)

    [reposted from http://phonegap.com as I realised you were unlikely to see it]

    System: OSX 10.8.2 and Xcode 4.5.2

    Owen

    January 13, 2013 at 7:42 pm

    • A new project doesn’t run? That’s indeed strange. It’s not broken, most likely something with your setup. If you want to package your sample project (this is a new project right?) and put it up somewhere, I can take a look.

      shazron

      January 13, 2013 at 7:46 pm

      • 2 sample projects: http://oocq.org/temp/Archive.zip (one working, one not)

        Upon creating another sample project it did build. Only obvious difference is the xcode project starts with a number, I guess that’s breaking it.

        With regards to migrating a 2.3 to 2.3 (I created another sample project and copied my www in), any ideas about the safari console error ‘file:///!gap_execFailed to load resource:’?

        Owen

        January 13, 2013 at 8:14 pm

      • Looks like this bug: https://issues.apache.org/jira/browse/CB-1476 but it was fixed a long time ago.

        shazron

        January 14, 2013 at 10:06 pm

  12. So is it now impossible to retrieve the old device.name value on iOS? (e.g. ‘Shazron’s iPhone 5′)?

  13. Upgraded to 2.3.0 last night, very smooth.

    My only glitch, and pardon my ignorance here, is that I find the guides (https://github.com/apache/cordova-ios/blob/master/guides/Cordova%20Plugin%20Upgrade%20Guide.md) to set the whitelisting correct for InAppBrowser extremely confusing.

    While I’m sure there was good reason to have plugins ignore the app whitelist, I’m not really sure how to use the InAppBrowser so that it follows my whitelist settings. Am I supposed to directly edit the InAppBrowser plugin itself?

    Kris

    January 30, 2013 at 3:26 pm

    • All the core plugins as defined in http://docs.phonegap.com do follow the whitelist, except for InAppBrowser, which is by design. I invite you to file an enhancement issue at http://issues.cordova.io (with a use case) so the devs can discuss the need for this.

      shazron

      January 30, 2013 at 6:20 pm

      • Thanks for the quick reply. I will look into adding an enhancement request.

        Kris

        January 30, 2013 at 6:31 pm

  14. This was helpful. I came across this while updating an old StackOverflow Answer http://stackoverflow.com/a/11418415/773263

    We met in BlackBerry Jam in Amsterdam, thought I’d say hi.

    PhilipK

    February 25, 2013 at 12:29 am

    • Thanks Phillip! Was great meeting you at BB Jam EU, drop by the Adobe SF office if you are in town :)

      shazron

      February 25, 2013 at 5:37 am

  15. The config.xml’s is overwriting Xcode’s “build” value … any way to fix this?

    Chris

    July 1, 2014 at 1:11 pm

  16. Sorry my previous comment was truncated:

    The config.xml’s widget “version” attribute is overwriting Xcode’s “build” value … any way to fix this?

    Chris

    July 2, 2014 at 10:43 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,531 other followers

%d bloggers like this: