S'abonner à un appareil
Cette page explique comment obtenir une mise à jour des informations d'un appareil à chaque modification.
Name
Value
Exemples d'implementation
// Importer le polyfill
const { EventSourcePolyfill } = require('event-source-polyfill');
// Ton Bearer Token
const token = 'votre token';
// Utiliser EventSourcePolyfill pour envoyer le token dans l'en-tête Authorization
const eventSource = new EventSourcePolyfill('https://mdm.pulse-xr.com/devices/:id/updates', {
headers: {
Authorization: `Bearer ${token}`,
},
});
eventSource.onopen = function (data) {
console.log('connection opened ');
};
eventSource.onmessage = function (event) {
const updatedDevice = JSON.parse(event.data);
console.log('Mise à jour du device:', updatedDevice);
};
eventSource.onerror = function (err) {
console.error('Erreur dans la connexion SSE:' + err);
};{
"id": string,
"enrollmentToken": string,
"enterprise": Enterprise,
"macAddress": string,
"androidId": string, // nullable
"description": string, // nullable
"temporaryVerificationCode": TemporaryVerificationCode, // nullable
"settings": Settings,
"type": TypeDevice,
"isAvailable": boolean,
"mdmInfo": { "codeVersion": integer, "labelVersion": string, "isDeviceOwner": boolean } //nullable,
"label": string,
"networksAvailable": NetworksDetails[],
"currentContent": CurrentContent,
"syncDate": Date,
"licence": string //nullable
}Mis à jour