OS1 Services
...
Location Tracking
Smartphone Tracking
9 min
introduction smartphone tracking enables app developers to locate devices using mobile network connectivity and signaling interfaces it provides real time location monitoring of smartphones this developer guide explains how to integrate with the motion tracking service (mts) platform to add smartphone tracking capabilities to your applications integration flow integrating smartphone tracking with your applications involves the following steps create a track use createtrack to create a new tracking request start/stop tracking use updatetrack to initiate tracking a device to obtain real time or periodic location data, or to stop tracking a device when it is no longer needed or at the end of the consent period retrieve data gettracedata to retrieve the device location tracking data step 1 create a location track call createsmartphonetrack to initiate tracking for a device the request requires the contextd note that any created tracks not started within 24 hours will be deleted see the request body parameters below true false 189false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type example request { "contextid" "ref 0f197669 f36e 4c9d 9d5d 8d673b1b8b4e", "defaultstart" false, "expiry" "3d", "callback" { "url" "https //example com/sim tracking callbacks", "meta" {}, "secret" "c2vjcmv0" } } example response { "error" {}, "data" { "trackid" "mts\ track 497cff90 a8b4 e4cc 0083 b2b16071ba1a", "trackname" "my new smart phone track" } } the response includes the data object containing the trackid and trackname step 2 start or stop tracking call updatesmartphonetrack to start or stop tracking by passing start or stop in request body see the request parameters below you can start or stop a track using the trackid or trackname path parameters true falsefalse unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type body parameters true false 143false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type the example request below starts tracking { "operation" "start", "callback" { "url" "https //myserver com/callbacks", "meta" {}, "secret" "string" } } on success, the api returns a 202 response with an id { "data" { "id" "mts\ track\ eaed3c14 b990 4f20 e911 bb31c4fde895" } } step 3 get location data after the tracking has started, an application will need to call gettracedata using the trackname or trackid to get the trace points of the device in geojson format step 4 get tracking status developers can use the following apis to retrieve the tracking status these apis returns the status of tracking (started/stopped) associated with the given deviceid with details such as trackingid and the duration of tracking getphonetrackstatusbycontextid getphonetrackstatusbyname getphonetrackstatusbyid gettrackingstatus { "data" { "status" "started", "trackid" "mts\ track 62b77d4a 6487 48bd 98b9 5013d8aefcbf", "trackname" "my sim track", "startedat" 1678011594259, "stoppedat" 0, "contextid" "ref 0d8fef84 baac 46c9 8cf0 77c5b9abf2de", "app" "com myapp", "totaltraces" 364, "routestats" { "confidence" "high", "distance" 10450, "errorreason" null } } }