Class: EvamApi

EvamApi.EvamApi

Evam API singleton that exposes methods to interact with the Evam platform.

Example

// Get instance (don't be afraid to copy them around or create more, as they're simply a lightweight reference to shared static data)
const evamApi = new EvamApi();

// Register a new callback on any operation update that simply logs it
evamApi.onNewOrUpdatedActiveOperation((activeOperation) => console.log(activeOperation));

// Register a new callback on any application settings update that simply logs them
evamApi.onNewOrUpdatedSettings((settings) => console.log(settings));

//Register a new callback to any specific application data update. Available register methods:
evamApi.onNewOrUpdatedDeviceRole((deviceRole) => ...);
evamApi.onNewOrUpdatedLocation((location) => ...);
evamApi.onNewOrUpdatedInternetState((internetState) => ...);
evamApi.onNewOrUpdatedVehicleState((vehicleState) => ...);
evamApi.onNewOrUpdatedTripLocationHistory((tripLocationHistory) => ...);

// Send a new notification to VS (this will also work for the developer environment)
// This will display a notification with heading "example", description "lorem ipsum". It will have type 'QUICK_HUN' and a primary button
// which is labelled 'primary button' that doesn't do anything when called. The secondary button is not defined, thus it will not display.
evamApi.sendNotification(new Notification("example","lorem ipsum", NotificationType.QUICK_HUN, {label:'primary button', callback:()=>{}}, undefined))

//Remove all callbacks from the SDK (this is useful for cleanup)
evamApi.unsubscribeFromAllCallbacks()

//Detect whether the certified app is currently running in Vehicle Services
EvamApi.isRunningInVehicleServices

//update the current hospital by id (be sure that the hospital is listed in available hospitals)
evamApi.setHospital(1234)

//update the current priority (be sure that the priority is listed in available priorities)
evamApi.setPriority (1)

//simulate Vehicle Services data inject (development + testing only)
//DO NOT USE THESE METHODS IN PRODUCTION, While not breaking by any means they will not perform any function.
evamApi.injectLocation(new Location(59.364, 18.012, new Date()))
evamApi.injectVehicleState(new VehicleState(...))
evamApi.injectTrip(new TripLocationHistory(...))
evamApi.injectDeviceRole(new DeviceRole(...))
evamApi.injectInternetState(new InternetState(...))
evamApi.injectOperation(new Operation(...))
evamApi.injectSettings(new Settings(...))
evamApi.injectOperationList([new Operation(...), new Operation(...), ...])
evamApi.injectBattery(new Battery(...)))

Constructors

constructor

new EvamApi()

Properties

store

store: Object

Store used for persisting data within Vehicle Services. If you are in development and not running your application within vehicle services then this will serve as a lightweight wrapper around localstorage. To avoid naming conflicts AppId must be set as it is used to identify application items.

Type declaration

Name

Type

clear

() => void

delete

(key: string) => void

get

(key: string) => string

set

(key: string, value: string) => void


isRunningInVehicleServices

Static isRunningInVehicleServices: boolean = isRunningInVehicleServices

Methods

deleteNavLayer

deleteNavLayer(id): void

Deletes a layer by its ID. A certified app can only delete a layer it has created.

Parameters

Name

Type

Description

id

string

the id of the layer (if the layer doesn’t exist then one will be created)

Returns

void

Requires

Permissions NAVIGATION_PRIVATE_LAYERS

Preview

This function is currently available in the Development Environment only.


getAppId

getAppId(): string

Gets the Evam App id as given by Vehicle Services

Returns

string


getAppVersion

getAppVersion(): string

Gets the Evam App version as defined in the evam.json manifest

Returns

string


getDeviceId

getDeviceId(): string

Gets the device ID as defined in Android

Returns

string


getGRPC

getGRPC(): GRPC

Gets the address for the GRPC proxy

Returns

GRPC


getOSVersion

getOSVersion(): string

Gets the Android OS version

Returns

string


getVehicleServicesVersion

getVehicleServicesVersion(): string

Gets the Vehicle Services app version

Returns

string


injectAppId

injectAppId(appId): void

Parameters

Name

Type

appId

string

Returns

void


injectAppVersion

injectAppVersion(appVersion): void

Parameters

Name

Type

appVersion

string

Returns

void


injectAvailableVehicleStatusList

injectAvailableVehicleStatusList(vehicleStatusList): void

Manually inject the Available Vehicle Status list to EvamApi (Only available in development.)

Parameters

Name

Type

Description

vehicleStatusList

VehicleStatus[]

the list of available Vehicle Statuses

Returns

void


injectBattery

injectBattery(battery): void

Injects the battery manually. This will trigger onNewOrUpdatedBattery(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

battery

Battery

The battery to be injected for development purposes.

Returns

void


injectDeviceRole

injectDeviceRole(deviceRole): void

Manually inject deviceRole to EvamApi (Only available in development.)

Parameters

Name

Type

Description

deviceRole

DeviceRole

the deviceRole to inject.

Returns

void


injectDisplayMode

injectDisplayMode(displayMode): void

Injects the display mode manually. This will trigger onNewOrUpdatedDisplayMode(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

displayMode

DisplayMode

The display mode (light or dark) to be injected for development purposes.

Returns

void


injectInternetState

injectInternetState(internetState): void

Manually inject internetState to EvamApi (Only available in development.)

Parameters

Name

Type

Description

internetState

InternetState

the internetState to inject.

Returns

void


injectLocation

injectLocation(location): void

Manually inject location to EvamApi (Only available in development.)

Parameters

Name

Type

Description

location

Location

the location to inject.

Returns

void


injectOSVersion

injectOSVersion(osVersion): void

Parameters

Name

Type

osVersion

string

Returns

void


injectOperation

injectOperation(activeCase): void

Injects the Active Operation manually. This will trigger onNewOrUpdatedActiveOperation(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

activeCase

Operation

The active case to be injected for development purposes.

Returns

void


injectOperationList

injectOperationList(operationList): void

Injects the operation list manually. This will trigger onNewOrUpdatedOperationList(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

operationList

Operation[]

The operation list to be injected for development purposes.

Returns

void


injectRakelMessages

injectRakelMessages(rakelMessages): void

Inject a list of raw Rakel messages as they would be received from the radio. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

rakelMessages

string[]

list of raw Rakel messages.

Returns

void


injectRakelState

injectRakelState(rakelState): void

Manually inject the Rakel State to EvamApi (Only available in development.)

Parameters

Name

Type

Description

rakelState

RakelState

The Rakel State

Returns

void


injectSettings

injectSettings(settings): void

Injects the settings manually. This will trigger onNewOrUpdatedSettings(…)’s callback. This function is to be used for development only and will throw an error when used in Vehicle Services.

Parameters

Name

Type

Description

settings

any

The settings to be injected for development purposes.

Returns

void


injectTrip

injectTrip(tripLocationHistory): void

Manually inject tripLocationHistory to EvamApi (Only available in development.)

Parameters

Name

Type

Description

tripLocationHistory

TripLocationHistory

the tripLocationHistory to inject.

Returns

void


injectVSVersion

injectVSVersion(vsVersion): void

Parameters

Name

Type

vsVersion

string

Returns

void


injectVehicleState

injectVehicleState(vehicleState): void

Manually inject vehicleState to EvamApi (Only available in development.)

Parameters

Name

Type

Description

vehicleState

VehicleState

the vehicleState to inject.

Returns

void


onNewOrUpdatedActiveOperation

onNewOrUpdatedActiveOperation(callback): void

Registers a callback to be run upon a new Active Operation is available or the current Active Operation is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Operation, void>

The callback to be executed

Returns

void

Requires

Permissions ACTIVE_OPERATION_READ


onNewOrUpdatedAvailableVehicleStatusList

onNewOrUpdatedAvailableVehicleStatusList(callback): void

Used to assign a callback when the list of available Vehicle Statuses is created or updated

Parameters

Name

Type

Description

callback

CallbackFunction<VehicleStatus[], void>

The callback with (optional) argument available Vehicle Status list. Use this to access the available Vehicle Statuses.

Returns

void

Requires

Permissions AVAILABLE_VEHICLE_STATUS_LIST_READ

Preview

This function is currently available in the Development Environment only.


onNewOrUpdatedBattery

onNewOrUpdatedBattery(callback): void

Used to assign a callback when the battery data is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Battery, void>

The callback with (optional) argument battery. Use this to access the battery.

Returns

void

Requires

Permissions BATTERY_READ


onNewOrUpdatedDeviceRole

onNewOrUpdatedDeviceRole(callback): void

Registers a callback to be run upon new device role or device role update

Parameters

Name

Type

Description

callback

CallbackFunction<DeviceRole, void>

The callback to be executed.

Returns

void

Requires

Permissions DEVICE_ROLE_READ


onNewOrUpdatedDisplayMode

onNewOrUpdatedDisplayMode(callback): void

Used to assign a callback when the battery created or updated.

Parameters

Name

Type

Description

callback

CallbackFunction<DisplayMode, void>

The callback with (optional) argument display mode. Use this to access the display mode.

Returns

void

Requires

Permissions DISPLAY_MODE_READ


onNewOrUpdatedInternetState

onNewOrUpdatedInternetState(callback): void

Registers a callback to be run upon new internetState or internetState update

Parameters

Name

Type

Description

callback

CallbackFunction<InternetState, void>

The callback to be executed.

Returns

void

Requires

Permissions CONNECTIVITY_READ


onNewOrUpdatedLocation

onNewOrUpdatedLocation(callback): void

Registers a callback to be run upon new location or location update

Parameters

Name

Type

Description

callback

CallbackFunction<Location, void>

The callback to be executed.

Returns

void

Requires

Permissions LOCATION_READ


onNewOrUpdatedOperationList

onNewOrUpdatedOperationList(callback): void

Used to assign a callback when the operation list is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<Operation[], void>

The callback with (optional) argument operationList. Use this to access the operation list.

Returns

void

Requires

Permissions OPERATION_READ


onNewOrUpdatedRakelMessages

onNewOrUpdatedRakelMessages(callback): void

Used to assign a callback when the incoming Rakel messages are updated. The messages are piped though in the raw form as they are received from the radio.

Parameters

Name

Type

Description

callback

CallbackFunction<string[], void>

The callback with (optional) argument Rakel messages. Use this to access the incoming Rakel messages.

Returns

void

Requires

Permissions RAKEL_COMMUNICATION_READ

Preview

This function is currently available in the Development Environment only.


onNewOrUpdatedRakelState

onNewOrUpdatedRakelState(callback): void

Used to assign a callback when the rakel state is created or updated

Parameters

Name

Type

Description

callback

CallbackFunction<RakelState, void>

The callback with (optional) argument Rakel state. Use this to access the Rakel state.

Returns

void

Requires

Permissions RAKEL_STATE_READ

Preview

This function is currently available in the Development Environment only.


onNewOrUpdatedSettings

onNewOrUpdatedSettings(callback): void

Registers a callback to be run upon new application settings reception or settings update

Parameters

Name

Type

Description

callback

CallbackFunction<any, void>

The callback to be executed.

Returns

void


onNewOrUpdatedTripLocationHistory

onNewOrUpdatedTripLocationHistory(callback): void

Used to assign a callback when the trip location history is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<TripLocationHistory, void>

The callback with (optional) argument tripLocationHistory. Use this to access the trip location history.

Returns

void

Requires

Permissions TRIP_HISTORY_READ


onNewOrUpdatedVehicleState

onNewOrUpdatedVehicleState(callback): void

Used to assign a callback when the vehicle state is updated.

Parameters

Name

Type

Description

callback

CallbackFunction<VehicleState, void>

The callback with (optional) argument vehicleState. Use this to access the vehicle state.

Returns

void

Requires

Permissions VEHICLE_STATE_READ


sendNotification

sendNotification(notification): void

send a notification to vehicle services (or evam-dev-environment if using the dev environment)

Parameters

Name

Type

Description

notification

Notification

The notification to be sent

Returns

void

Requires

Permissions SEND_NOTIFICATION


sendRawRakelAction

sendRawRakelAction(rawRakelAction): void

Sends a RawRakelAction to the Rakel radio.

Parameters

Name

Type

Description

rawRakelAction

RawRakelAction

the RawRakelAction to be sent to the radio.

Returns

void

Requires

Permissions RAKEL_RAW_COMMAND_SEND


setHospital

setHospital(id): void

Sets the selected hospital id for the current active operation. The id must be present inside the available hospitals

Parameters

Name

Type

Description

id

number

the id of the hospital to be set

Returns

void

Requires

Permissions ACTIVE_OPERATION_WRITE


setNavLayerPoint

setNavLayerPoint(id, layerData): void

Adds/Update a layer by its ID. Reusing a layerID causes the data to be replaced. A certified app can only update a layer it has created. This function adds a set of points on the map with text and icon at the specified lat and lon

Parameters

Name

Type

Description

id

string

the id of the layer (if the layer doesn’t exist then one will be created)

layerData

LayerPointData[]

array of points to be shown with text and icon. Note that the icon of the first element will be used for all points.

Returns

void

Requires

Permissions NAVIGATION_PRIVATE_LAYERS

Preview

This function is currently available in the Development Environment only.


setNavLayerShape

setNavLayerShape(id, layerData): void

Adds/Update a layer by its ID. Reusing a layerID causes the data to be replaced. A certified app can only update a layer it has created. This function adds a set of shapes on the map with the text in its center.

Parameters

Name

Type

Description

id

string

the id of the layer (if the layer doesn’t exist then one will be created)

layerData

LayerShapeData[]

array of shapes to be shown with text and shape color (format: “#AARRGGBB”, just like the SC buttons)

Returns

void

Requires

Permissions NAVIGATION_PRIVATE_LAYERS

Preview

This function is currently available in the Development Environment only.


setPriority

setPriority(id): void

Sets the selected priority id for the current active operation. The id must be present inside the available priorities.

Parameters

Name

Type

Description

id

number

of the priority to be set

Returns

void

Requires

Permissions ACTIVE_OPERATION_WRITE


unsubscribeFromAllCallbacks

unsubscribeFromAllCallbacks(): void

Unsubscribes all registered callbacks from Vehicle Service events.

Returns

void