Device
Mixin Extends:
Helper class representing a device.
Example:
import { Device, deviceService } from 'clinical6';
// Typically use DeviceService.get()
deviceService.get().then(devices => console.log(devices));
const device = new Device({
"data": {
"id": "1",
"type": "devices",
"attributes": {
"udid": "this-is-a-udid-string",
"technology": "ios",
"access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
"push_id": null,
"created_at": "2017-05-19T17:21:26.311Z",
"updated_at": "2017-05-19T17:21:26.311Z",
"app_version": null
}
}
});
Method Summary
Public Methods | ||
public |
Saves a device (insert if id doesn't exist, update if it does) |
|
public |
Saves a device (insert if id doesn't exist, update if it does) |
|
public |
Select this device as the main device to use for authentication and http calls |
Inherited Summary
From class DeviceModel | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
Public Members
Public Methods
public delete(): Promise source
Saves a device (insert if id doesn't exist, update if it does)
Example:
import { Device, Client } from 'clinical6';
// Removes device from server and local storage
const device = new Device({
"id": 1,
"type": "devices",
"attributes": {
"udid": "this-is-a-udid-string",
"technology": "ios",
"access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
"push_id": null,
"created_at": "2017-05-19T17:21:26.311Z",
"updated_at": "2017-05-19T17:21:26.311Z",
"app_version": null
}
});
device.delete();
// No longer in storage
Client.instance.storageUtility.has('devices', { id: 1 });
public save(): Promise<Device> source
Saves a device (insert if id doesn't exist, update if it does)
Example:
import { Device, deviceService } from 'clinical6';
// Insert is different from other inserts. Uses mobile application key
const device = new Device({
"type": "devices",
"attributes": {
"udid": "this-is-a-udid-string",
"technology": "ios",
"access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
"push_id": null,
"created_at": "2017-05-19T17:21:26.311Z",
"updated_at": "2017-05-19T17:21:26.311Z",
"app_version": null
}
});
Client.instance.mobileApplicationKey='12345';
device.save();
// After you have the authtoken and then you've logged in
// Updates existing device (has existing id)
deviceService.get().then(devices => devices[0].save());