View
 

JavaScript API

Page history last edited by Bryce Curtis 1 year, 6 months ago

JavaScript API 'Staging'

 


NOTE:  This page is obsolete.  The most recent documentation is available at http://docs.phonegap.com.


 

Using this page for now as a page that will have the latest up-to-date JavaScript API information. Eventually we want to move this page and the info contained within it to docs.phonegap.com.

 

Geolocation

Related PhoneGap Tutorials

 

JavaScript Geolocation Interface

Geolocation class

  readonly attribute Position lastPosition

     - Set to the last-retrieved GPS position after every successful location retrieval. 

 

  void getCurrentPosition(successCallback, [errorCallback], [options])

     - Retrieves the current GPS system position from the device.

     - successCallback parameter: handle to a function taking one parameter that handles what to do with the retrieved position. Parameter for this function will be an instance of the Position class.

     - errorCallback parameter (optional): handle to a function that handles error in retrieving position.

     - options parameter (optional): JavaScript object literal defining members specifying options to the call. For getCurrentPosition, none that apply (yet).

 

  int watchPosition(successCallback, [errorCallback], [options])

     - Retrieves the current GPS position from the device at a specified interval.

     - Returns an ID to use with clearWatch function below when you want to clear the position watch.

     - successCallback parameter: handle to a function taking one parameter that handles what to do with the retrieved position. Parameter for this function will be an instance of the Position class.

     - errorCallback parameter (optional): handle to a function that handles error in retrieving position.

     - options parameter (optional): JavaScript object literal defining members specifying options to the call. For watchPosition, a 'frequency' member specifies how frequently to check for position (specified in milliseconds).

 

  void clearWatch(int watchId)

     - Clears out the watchPosition interval timeout, given the watchId to clear.

     - Use the ID returned by watchPosition function above as parameter to pass into this function.

 

Position class

  readonly attribute Coordinates coords

  readonly attribute Date timestamp

 

Coordinates class

  readonly attribute double latitude

  readonly attribute double longitude

  readonly attribute double altitude

  readonly attribute double accuracy

  readonly attribute double heading

  readonly attribute double speed 

 

Accelerometer

Accelerometer class

  readonly attribute Position lastPosition

  void getCurrentAcceleration(successCallback, [errorCallback], [options])

  int watchAcceleration(successCallback, [errorCallback], [options])

  void clearWatch(int watchId)

Camera

Camera class

  void getPicture(successCallback, [errorCallback], [options])

Notification

Notification class

  void beep()

  void vibrate()

  void blink()

  void watchPosition(filter, [successCallback], [errorCallback])

  void clearWatch(filter, [successCallback], [errorCallback])

  void onReceive(successCallback, errorCallback)

Contacts

Contacts class

  void getAllContacts(successCallback, [errorCallback], [options])

Contact class

  readonly attribute String name

  readonly attribute String[] phone

  readonly attribute String address

File IO

File class

  void read(fileName, [successCallback], [errorCallback])

  void write(fileName, data, mode, [successCallback], [errorCallback])

  void createDirectory(directory, [successCallback], [errorCallback])

  void deleteDirectory(directory, [successCallback], [errorCallback])

  boolean testDirectoryExists(directory, [successCallback], [errorCallback])

  void deleteFile(file, [successCallback], [errorCallback])

  boolean testFileExists(file, [successCallback], [errorCallback])

  long getFreeDiskSpace([successCallback], [errorCallback])

SMS

SMS class

  void send(number, message, [successCallback], [errorCallback])

Phone

Phone class

  void call(number, [successCallback], [errorCallback])

Maps

Map class

  void open(positions, [successCallback], [errorCallback])

Audio

Audio class

  void startRecording(file, encoding, successCallback, [errorCallback])

  void stopRecording(successCallback, [errorCallback])

  void startPlaying(filename, channel, successCallback, [errorCallback])

  void stopPlaying(channel, successCallback, [errorCallback])

  long getDuration(filename, successCallback, [errorCallback])

  long getCurrentPosition(filename, successCallback, [errorCallback])

  void setOutputDevice(device, successCallback, [errorCallback])

  string getOutputDevice(successCallback, [errorCallback])

Settings

Settings class

  string getNetworkOperatorName([successCallback], [errorCallback])

  string getVoicemailNumber([successCallback], [errorCallback])

  string getTimeZoneID([successCallback], [errorCallback])

  string getSimCountryIso([successCallback], [errorCallback])

  string getLine1Number([successCallback], [errorCallback])

HTTP

HTTP class

  void get(url, file, channel, successCallback, [errorCallback])