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 |
---|---|
|
() => |
|
( |
|
( |
|
( |
isRunningInVehicleServices¶
Static
isRunningInVehicleServices: boolean
= isRunningInVehicleServices
Methods¶
answerCall¶
answerCall(callId
): void
Answers a call that matches the given callId provided as part of the calls from newOrUpdatedCalls.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
the id of the call to answer. |
Returns¶
void
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¶
getOSVersion¶
getOSVersion(): string
Gets the Android OS version
Returns¶
string
getVehicleServicesVersion¶
getVehicleServicesVersion(): string
Gets the Vehicle Services app version
Returns¶
string
hangUpCall¶
hangUpCall(callId
): void
Hangs up or canceles a call that matches the given callId provided as part of the calls from newOrUpdatedCalls.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
the id of the call to be canceled. |
Returns¶
void
holdCall¶
holdCall(callId
): void
Puts a call on hold that matches the given callId provided as part of the calls from newOrUpdatedCalls.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
the id of the call to hold. |
Returns¶
void
injectAppId¶
injectAppId(appId
): void
Parameters¶
Name |
Type |
---|---|
|
|
Returns¶
void
injectAppVersion¶
injectAppVersion(appVersion
): void
Parameters¶
Name |
Type |
---|---|
|
|
Returns¶
void
injectAvailableVehicleStatusList¶
injectAvailableVehicleStatusList(vehicleStatusList
): void
Manually inject the Available Vehicle Status list to EvamApi (Only available in development.)
Parameters¶
Name |
Type |
Description |
---|---|---|
|
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 |
---|---|---|
|
The battery to be injected for development purposes. |
Returns¶
void
injectCalls¶
injectCalls(calls
): void
Inject a list of PhoneCall as they are sent from Vehicle Services. This function is to be used for development only and will throw an error when used in Vehicle Services.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
the calls to be injected. |
Returns¶
void
injectDeviceRole¶
injectDeviceRole(deviceRole
): void
Manually inject deviceRole to EvamApi (Only available in development.)
Parameters¶
Name |
Type |
Description |
---|---|---|
|
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 |
---|---|---|
|
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 |
---|---|---|
|
the internetState to inject. |
Returns¶
void
injectLocation¶
injectLocation(location
): void
Manually inject location to EvamApi (Only available in development.)
Parameters¶
Name |
Type |
Description |
---|---|---|
|
the location to inject. |
Returns¶
void
injectMuteState¶
injectMuteState(isMuted
): void
Injects the mute state of the microphone. This function is to be used for development only and will throw an error when used in Vehicle Services.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
true if the microphone is muted. |
Returns¶
void
injectOSVersion¶
injectOSVersion(osVersion
): void
Parameters¶
Name |
Type |
---|---|
|
|
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 |
---|---|---|
|
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 |
---|---|---|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
the tripLocationHistory to inject. |
Returns¶
void
injectVSVersion¶
injectVSVersion(vsVersion
): void
Parameters¶
Name |
Type |
---|---|
|
|
Returns¶
void
injectVehicleState¶
injectVehicleState(vehicleState
): void
Manually inject vehicleState to EvamApi (Only available in development.)
Parameters¶
Name |
Type |
Description |
---|---|---|
|
the vehicleState to inject. |
Returns¶
void
makeCall¶
makeCall(number
): void
Initiates a new call to the given {@argument number}.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
the phone number to call |
Returns¶
void
muteMicrophone¶
muteMicrophone(): void
Mutes the microphone of the device.
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
The callback with (optional) argument battery. Use this to access the battery. |
Returns¶
void
Requires
Permissions BATTERY_READ
onNewOrUpdatedCalls¶
onNewOrUpdatedCalls(callback
): void
Used to assign a callback when the phone calls are updated.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
The callback with (optional) argument array of PhoneCall. Use this to access the current phone calls. |
Returns¶
void
Requires
Permissions TELEPHONY
Preview
This function is currently available in the Development Environment only.
onNewOrUpdatedDeviceRole¶
onNewOrUpdatedDeviceRole(callback
): void
Registers a callback to be run upon new device role or device role update
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
The callback to be executed. |
Returns¶
void
Requires
Permissions LOCATION_READ
onNewOrUpdatedMuteState¶
onNewOrUpdatedMuteState(callback
): void
Used to assign a callback when the device’s microphone mute state is updated.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
The callback with (optional) argument boolean. Use this to access the current microphone mute state. |
Returns¶
void
Requires
Permissions TELEPHONY
Preview
This function is currently available in the Development Environment only.
onNewOrUpdatedOperationList¶
onNewOrUpdatedOperationList(callback
): void
Used to assign a callback when the operation list is updated.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
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 |
---|---|---|
|
|
The callback with (optional) argument vehicleState. Use this to access the vehicle state. |
Returns¶
void
Requires
Permissions VEHICLE_STATE_READ
putAppInForeground¶
putAppInForeground(): void
Opens the app in foreground in Vehicle Services.
Returns¶
void
removeNotification¶
removeNotification(notificationId
): void
Removes the notification by given id.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
The notification id |
Returns¶
void
sendNotification¶
sendNotification(notification
): void
send a notification to vehicle services (or evam-dev-environment if using the dev environment)
Parameters¶
Name |
Type |
Description |
---|---|---|
|
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 |
---|---|---|
|
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 |
---|---|---|
|
|
the id of the hospital to be set |
Returns¶
void
Requires
Permissions ACTIVE_OPERATION_WRITE
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 |
---|---|---|
|
|
of the priority to be set |
Returns¶
void
Requires
Permissions ACTIVE_OPERATION_WRITE
unholdCall¶
unholdCall(callId
): void
Resumes a call on hold that matches the given callId provided as part of the calls from newOrUpdatedCalls.
Parameters¶
Name |
Type |
Description |
---|---|---|
|
|
the id of the call to be resumed. |
Returns¶
void
unmuteMicrophone¶
unmuteMicrophone(): void
Unmutes the microphone of the device.
Returns¶
void
unsubscribeFromAllCallbacks¶
unsubscribeFromAllCallbacks(): void
Unsubscribes all registered callbacks from Vehicle Service events.
Returns¶
void