PhoneGap APIs

The Hybrid Web Container comes with the PhoneGap library linked in and ready to use.

The PhoneGap library included with Sybase Unwired Platform handles common tasks supported by Android and iOS devices, for example, accessing geolocation, accessing contacts, and invoking calls to make those common functions available to JavaScript.

Note: Keep in mind that PhoneGap APIs cannot be accessed successfully until certain initialization has taken place. If you make calls to the PhoneGap API from the customAfterShowScreen function, they should occur only after the PhoneGap subsystem is initialized and ready to execute these calls. For more information, see http://wiki.phonegap.com/w/page/36868306/ UI%20Development%20using%20jQueryMobile#HandlingPhoneGapsdevicereadyevent.

You can make PhoneGap calls from the Hybrid Web Container JavaScript, such as Custom.js. For example, to save an entry to the contacts database, you can implement something similar to:

        var contact = navigator.contacts.create();
        contact.nickname = "Plumber";       
        var name = new ContactName();
        name.givenName = "Jane";
        name.familyName = "Doe";
        contact.name = name;
        // save
        contact.save(onSaveSuccess,onSaveError);