Skip to content

API Documentation & Usage Guide Android

Umer Asif edited this page Oct 20, 2016 · 8 revisions

Setting up the SDK

Overview

Details

Start predict.io

This starts predict.io if the API_Key is set into plugin.xml, otherwise it returns an Error.

/**
 * Starts predict.io if API_Key is set into plugin.xml, otherwise it returns an Error
 *
 * @param "true/false" set high precision
 * @param "true/false" set searching in perimeter enable
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'start' , ['true/false' , 'true/false']);

Stop predict.io

This method stop predict.io

/**
 * Stop predict.io
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'stop', []);     

predict.io Status

This method returns predict.io's status, PredictIOStatus (i.e. if it is active or not).

/**
 * This method returns predict.io's status, PredictIOStatus (i.e. if it is active or not).
 *
 * @return PredictIOStatus which represents the current predict.io state.
 * ACTIVE: predict.io is in a working/running state.
 * LOCATION_DISABLED: predict.io is not in a working state, GPS is disabled from location settings.
 * AIRPLANE_MODE_ENABLED: predict.io is not in a working state, Airplane mode is enabled in settings.
 * INSUFFICIENT_PERMISSION: predict.io has not been authorized by user to use location services at any time.
 * IN_ACTIVE: predict.io has not been started. It is in inactive state.
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'status' , []);

Device Identifier

An alphanumeric string that uniquely identifies a device to predict.io.

/**
 * An alphanumeric string that uniquely identifies a device to the predict.io
 *
 * @return UUID
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'deviceIdentifier' , []);

predict.io Search

Use this method to enable/disable searching in perimeter.

/**
 * Enable/disable searching for parking
 *
 * @return "true/false"
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'isSearchingInPerimeterEnabled' , []);

predict.io Precision Status

Use this method to verify if predict.io is active in high precision mode or low precision mode

/**
 * Use this method to verify if predict.io is active in high precision mode or low precision mode
 *
 * @return "HIGH\LOW"
 */
 cordova.exec(successCallback , errorCallback , 'PredictIOPlugin' , 'precision' , []);

SDK Functions

Overview

  • Departed - Invoked when the user has just departed.
  • Departure Canceled - Invoked when the last departure event is unable to validate.
  • Transportation Mode - Invoked when transportation mode is detected.
  • Arrival Suspected - Invoked when predict.io suspects that the user has just arrived.
  • Arrived - Invoked when the user has just arrived at the destination.
  • Searching In Perimeter - Invoked when the user is searching for a parking space at a specific location.
  • Did Update Location - Invoked when new location information is received from location services.

###Details

Departed

This method is invoked when predict.io detects that the user has just departed

/**
 * This method is invoked when predict.io detects that the user has just departed
 * from his location and have started a new trip
 *
 * @param departureLatitude:  The latitude of the Location from where the user departed
 * @param departureLongitude: The longitude of the Location from where the user departed
 * @param departureTime:      Start time of the trip
 * @param transportMode:      Mode of transport
 * @param UUID:               Trip segment UUID
 */
 function departed(param) { }

Departure Canceled

This method is invoked when predict.io is unable to validate the last departure event.

/**
 * This method is invoked when predict.io is unable to validate the last departure event.
 * This can be due to invalid data received from sensors or the trip amplitude.
 * i.e. If the trip takes less than 5 minutes or the distance travelled is less than 1km
 */
 function departureCanceled() { }

Transportation Mode

This method is invoked when predict.io detects a transportation mode

/**
 * This method is invoked when predict.io detects transportation mode
 * @param transportationMode: Mode of transportation
 * @param UUID:               Trip segment UUID
 */
 function transportationMode(param) { }

Arrival Suspected

This method is invoked when predict.io suspects that the user has just arrived

/**
 * This method is invoked when predict.io suspects that the user has just arrived
 * at his location and have ended a trip
 * Most of the time it is followed by a confirmed arrived event
 * If you need only confirmed arrival events, use arrived method (below) instead
 *
 * @param departureLatitude:  The latitude of the Location from where the user departed
 * @param departureLongitude: The longitude of the Location from where the user departed
 * @param arrivalLatitude:    The latitude of the Location where the user arrived and ended the trip
 * @param arrivalLongitude:   The longitude of the Location where the user arrived and ended the trip
 * @param departureTime:      Start time of the trip
 * @param arrivalTime:        Stop time of the trip
 * @param transportMode:      Mode of transport
 * @param UUID:               Trip segment UUID
 */
 function arrivalSuspected(param) { }

Arrived

This method is invoked when predict.io detects that the user has just arrived at destination.

/**
 * This method is invoked when predict.io detects that the user has just arrived at destination
 *
 * @param arrivalLatitude:    The latitude of the Location where the user arrived and ended the trip
 * @param arrivalLongitude:   The longitude of the Location where the user arrived and ended the trip
 * @param departureLatitude:  The latitude of the Location from where the user departed
 * @param departureLongitude: The longitude of the Location from where the user departed
 * @param departureTime:      Start time of the trip
 * @param arrivalTime:        Stop time of the trip
 * @param transportMode:      Mode of transport
 * @param UUID:               Trip segment UUID
 */
 function arrived(param) { }

Searching In Perimeter

This method is invoked when predict.io detects that the user is searching for a parking space at a specific location in his/her car.

/**
 * This method is invoked when predict.io detects that the user is searching for a
 * parking space at a specific location
 * @param latitude:  The latitude of the Location where predict.io identifies that user is searching for a parking space
 * @param longitude: The longitude of the Location where predict.io identifies that user is searching for a parking space
 */
 function searchingInPerimeter(param) { }

Did Update Location

This method is invoked when new location information is received from location services

/**
 * This is invoked when new location information is received from GPS
 * Implemented this method if you need raw GPS data, instead of creating new location manager
 * Since, it is not recommended using multiple location managers in a single app
 * @param latitude:  The latitude of the new location received from GPS
 * @param longitude: The longitude of the new location received from GPS
 */
 function didUpdateLocation(param) { }