Supported JavaScript PhoneGap APIs

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

The PhoneGap library included with SAP Mobile Platform handles common native tasks supported by Android, BlackBerry, iOS and Windows Mobile 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 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);

You can use both Hybrid Web Container JavaScript APIs and PhoneGap APIs in a single application. For information about PhoneGap APIs, see http://docs.phonegap.com.

PhoneGap Supported Features
API Object and Function Platform
Accelerometer    
  accelerometer
  • getCurrentAcceleration
    Note: On iOS, this function must be called after watchAcceleration.
  • watchAcceleration
  • clearWatch
  • Android
  • iOS
  • BlackBerry
  Acceleration
  • x
  • y
  • z
  • timeStamp
  • Android
  • BlackBerry
  • iOS
Camera    
  Camera
  • getPicture (Camera.PictureSourceType.CAMERA)
  • getPicture (Camera.PictureSourceType.PHOTOLIBRARY)
  • getPicture (Camera.PictureSourceType.SAVEDPHOTOALBUM)
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
CameraOptions
  • quality
  • dedestinationType.DATA_URL
  • dedestinationType.FILE_URI

    FILE_URI is the default.

  • allowEdit
  • encodingType
  • targetWidth
  • targetHeight
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Capture    
  Capture
  • captureAudio
    Note: On Android, whether this works depends on which application the device uses to record the audio. You can use media.record instead to work around this issue.
  • captureImage
  • captureVideo
  • Android
  • BlackBerry
  • iOS
MediaFile
  • getFormatData
  • Android
  • iOS
Compass    
  compass
  • getCurrentHeading
  • watchHeading
  • clearWatch
  • watchHeadingFilter
  • Android
  • iOS
compass.Heading
  • magneticHeading
  • trueHeading
  • headingAccuracy
  • timestamp
  • Android
  • iOS
Connection    
  network.connection.type
  • Android
  • BlackBerry
  • iOS
Contacts    
  contacts.create
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  contacts.find
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  contact.clone
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  Contacts.remove
Note: On Android, there is an issue with contacts not being fully removed. See https://issues.apache.org/jira/browse/CB-75.
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  Contacts.save
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Device    
  Device.name
  • Android
  • BlackBerry
  • iOS
  Device.phonegap
  • Android
  • BlackBerry
  • iOS
  Device.platform
  • Android
  • BlackBerry
  • iOS
  Device.uuid
  • Android
  • BlackBerry
  • iOS
  Device.version
  • Android
  • BlackBerry
  • iOS
Events    
  Deviceready
  • Android
  • iOS
  Pause
  • Android
  Resume
  • Android
  Online
  • Android
  • iOS
  Offline
  • Android
  • iOS
  Batterycritical iOS
  Batterylow iOS
  Batterystatus
Note: On Android, PhoneGap 1.4.1, this does not work due to a known issue. See https://issues.apache.org/jira/browse/CB-173.
iOS
  Menubutton
  • Android
  Searchbutton
  • Android
File    
  DirectoryEntry
  • copyTo
  • moveTo
  • toURI
  • remove
  • removeRecursively
  • getParent
  • createReader
  • getDirectory
  • getFile
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  FileEntry
  • copyTo
  • moveTo
  • toURI
  • remove
  • getParent
  • createWriter
  • file
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  FileReader
  • abort
  • readAsDataURL
  • readAsText
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  FileWriter
  • abort
  • seek
  • truncate
  • write
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  DirectoryReader
  • readEntries
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  LocalFileSystem
  • requestFileSystem
  • resolveLocalFileSystemURI
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  FileTransfer
  • upload
  • download
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Geolocation    
  geolocation
  • getCurrentPosition
    Note: This function does not work on the Android Galaxy Tab P1000 device.
  • watchPosition
  • clearWatch
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  Position
  • coords
  • timestamp
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
  Coordinates
  • latitude
  • longitude
  • altitude
  • accuracy
    Note: On Android, the returned accuracy property is always null.
  • altitudeAccuracy
    Note: On Android, the returned altitudeAccuracy property is always null.
  • heading
    Note: Android only. The returned heading property is always null.
  • speed
    Note: On Android, the returned speed property is always null.
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Media    
  Media.play
  • Android
  • iOS
  • Windows Mobile
Media.pause
  • Android
  • iOS
Media.stop
  • Android
  • iOS
  • Windows Mobile
Media.release
  • Android
  • iOS
Media.record
  • Android
  • iOS
Media.startRecord
  • Android
  • iOS
Media.stopRecord
  • Android
  • iOS
  • Windows Mobile
Media.getCurrentPosition
  • Android
  • iOS
  • Windows Mobile
Media.seekTo
  • Android
  • iOS
  • Windows Mobile
Media.getDuration
Note: On Android, this function returns a value without an error but always returns -1, which indicates duration is not available.
  • Android
  • iOS
  • Windows Mobile
Notification    
  Notification.beep
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Notification.confirm
  • Android
  • BlackBerry
  • iOS
Notification.alert
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Notification.vibrate
  • Android
  • BlackBerry
  • iOS
  • Windows Mobile
Storage    
  window
  • OpenDatabase
  • Android
  • BlackBerry
  • iOS
Database
  • transaction
  • Android
  • BlackBerry
  • iOS
SQLTransaction
  • executeSQL
Note: On Android, queries on the first database created do not work. You can work around this by creating and opening two databases, the first of which can have the size of 0, and the second to use as you normally do. For example:
var db = window.openDatabase("aName1", "1.0", "aName1", 0);
db = window.openDatabase("aName2", "1.0", "aName2", 200000);
  • Android
  • BlackBerry
  • iOS
SQLResultSet
  • insertid
  • rowAffected
    Note: The returned SQLResultSet object does not contain a rowAffected property, as the PhoneGap API states. Instead, use rowsAffected.
  • rows
  • Android
  • BlackBerry
  • iOS
SQLResultSetList
  • item
  • length
  • Android
  • BlackBerry
  • iOS
SQLError
  • code
  • message
  • Android
  • BlackBerry
  • iOS
localStorage
  • key
  • getitem
  • setitem
  • removeitem
  • clear
iOS