Kiểm tra thiết bị với key tương ứng có tồn tại trong dự án hay không. Trả về
Device().IdentifyInfoByKey({key: string})
Phiên bản cũ
try {
let data = await Device().IdentifyInfoByKey({ key: '0000000'});
let deviceInfo = data.toObject();
} catch (any) {
//handle error not found device
};
Phiên bản mới
let res = await Device().IdentifyInfoByKey({ key: '0000000'});
if (res.success){
// Thiết bị tồn tại
let deviceInfo = res.data;
}else{
// Thiết bị không tồn tại
}
IdentifyInfoByKeyWithAd
Kiểm tra thiết bị với thông tin key, projectId có tồn tại hay không. Trả về
try {
let data = await Device().IdentifyInfoByKeyWithAd({ key: '0000000', projectId: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'});
let deviceInfo = data.toObject();
} catch (any) {
//handle error not found device
};
Phiên bản mới
let res = await Device().IdentifyInfoByKeyWithAd({ key: '0000000', projectId: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'});
if (res.success){
// Thiết bị tồn tại
let deviceInfo = res.data;
}else{
// Thiết bị không tồn tại
}
Có thể dùng trường key để lưu định danh thiết bị (imei, serial,...)
Phiên bản cũ
let createDevice = await Device().CreateDevice({ name: 'new_device', key: '00000');
let deviceInfo= createDevice.toObject();
return deviceInfo;
Phiên bản mới
let createDevice = await Device().CreateDevice({ name: 'new_device', key: '00000');
if (createDevice.success){
// Tạo thiết bị thành công
let deviceInfo = createDevice.data;
}else{
// Tạo thiết không bị thành công
}
IdentifyInfo
Device().IdentifyInfo({id: string})
Phiên bản cũ
let res = await Device().IdentifyInfo({id: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'})
deviceInfo = res.toObject();
return deviceInfo;
Phiên bản mới
let res = await Device().IdentifyInfo({id: 'c53f1597-d04a-470f-9f76-3c40a11e43b2'})
if (res.success){
// Thiết bị tồn tại
deviceInfo = res.data;
}else{
// Thiết bị không tồn tại
}