The Motion-S Mobile SDK is a set of libraries for Android, iOS and the IONIC/Cordova framework, which can be used natively on Android/iOS or with cross-platform frameworks. The mobile SDK collects trip data and uploads it automatically to the Motion-S platform with the following structure:

{
  "startTimestamp": 1512454642000,
  "endTimestamp": 1512554642000,
  "device": "device-id",
  "foreignKey":"18bb9f27",
  "origin": "<customer-name>-<fleet-name>-<fleet-number>",
  "locations":[
    {
      "id_loc": 1,
      "latitude":48.952283,
      "longitude":9.136845,
      "bearing":194.344284,
      "speedKmh":8.8560,
      "recordDateUTCTimestamp":1512454642000
    },
    ...
  ]
}

This information can also be uploaded to a custom endpoint defined by the customer. In this case, then the trip data has to be sent to the Motion-S platform through the API in the same format as received by the SDK.

Screenshots

SDK integration

The Motion-S Mobile SDK can be integrated with other applications depending on the customer needs. With this in mind, in this section we describe the usage of this library and the possible events from JavaScript/IONIC/Cordova.

Supported Versions

  • Android: 28+
  • iOS: 13.x

Actions

The Motion-S Interface currently describes three actions:

//Initializes the SDK (if not already done) and enables trip recording
cordova.plugins.motions.start();
//Pauses (but does not unload) the SDK
cordova.plugins.motions.finish();
//Forces trip uploading (if not already in progress; normally this is happening periodically)
cordova.plugins.motions.syncTrips();

Events

You can subscribe to events using the ionic broadcaster plug-in:

this.broadcaster.addEventListener( 'com.motions.sdk.client.STATE_CHANGED_BROADCAST_SDK').subscribe(x =>
  # x is a json
  x.EXTRA_DEVICEID The device id used in api calls [String]
  x.EXTRA_SDKSTATE The SDK state [0|1|2] (stopped, listening, heartbeat)
);

this.broadcaster.addEventListener( 'com.motions.sdk.client.STATE_CHANGED_BROADCAST_RECORDER').subscribe(x =>
   # x is a json
   x.EXTRA_RECORDERSTATE The trip recorder state [0|1|2] (idle,recording, error)
);

this.broadcaster.addEventListener( 'com.motions.sdk.client.STATE_CHANGED_BROADCAST_UPLOADER').subscribe(x =>
   # x is a json
   x.EXTRA_UPLOADERSTATE The uploader state [1|2|3] (working, success, error)
);