This example shows how to use the 51Degrees Cloud service to lookup
the details of a device based on a given 'native model name'.
Native model name is a string of characters that are returned from
a query to the device's OS. For more details on this, see the example below.
This example requires a subscription to 51Degrees Device Data, a subscription can be acquired from the 51Degrees pricing page.
Make sure to include the Profiles, HardwareVendor, HardwareModel and HardwareName properties as they are used by this example.
This example finds the details of devices from the 'native model name'.
The native model name can be retrieved by code running on the device (For example, a mobile app).
For Android devices, see https:
For iOS devices, see https:
----------------------------------------
Which devices are associated with the native model name 'SC-03L'?
Samsung Galaxy S10 (SC-03L)
Which devices are associated with the native model name 'iPhone11,8'?
Apple iPhone XR (iPhone XR)
Apple iPhone XR (A1984)
Apple iPhone XR (A2105)
Apple iPhone XR (A2106)
Apple iPhone XR (A2107)
Apple iPhone XR (A2108)
const pipelineCore = require('fiftyone.pipeline.core');
const CloudRequestEngine = require('fiftyone.pipeline.cloudrequestengine');
'/../../hardwareProfileCloudEngine');
const myResourceKey = process.env.RESOURCE_KEY || "!!YOUR_RESOURCE_KEY!!";
const myLicenseKey = "!!YOUR_LICENSE_KEY!!";
if (myResourceKey === "!!YOUR_RESOURCE_KEY!!" ||
myLicenseKey === "!!YOUR_LICENSE_KEY!!") {
console.log('You need to create a resource key at ' +
'https://configure.51degrees.com and paste it into the code, ' +
'replacing !!YOUR_RESOURCE_KEY!!');
console.log('You also need a subscription which can be acquired ' +
'from https://51degrees.com/pricing. Paste the license key into the ' +
'code, replacing !!YOUR_LICENSE_KEY!!.');
console.log('Make sure to include the Profiles, HardwareVendor, ' +
'HardwareModel and HardwareName properties as they are used by this ' +
'example.');
} else {
console.log(`This example finds the details of devices from the 'native model name'.
The native model name can be retrieved by code running on the device (For example, a mobile app).
For Android devices, see https:
For iOS devices, see https:
----------------------------------------`);
const requestEngineInstance = new CloudRequestEngine.CloudRequestEngine({
resourceKey: myResourceKey,
licenseKey: myLicenseKey
});
const PipelineBuilder = pipelineCore.PipelineBuilder;
const pipeline = new PipelineBuilder()
.add(requestEngineInstance)
.add(hardwareProfileCloudEngineInstance)
.build();
pipeline.on('error', console.error);
const outputDetails = async function (nativemodel) {
let message = `Which devices are associated with the native model name ` +
`'${nativemodel}'?`;
const flowData = pipeline.createFlowData();
flowData.evidence.add('query.nativemodel', nativemodel);
await flowData.process();
if (!flowData.hardware) {
console.log('Make sure to include the HardwareVendor, HardwareModel ' +
'and HardwareName properties as they are used by this example.');
return;
}
flowData.hardware.profiles.forEach(profile => {
const hardwareVendor = profile.hardwarevendor;
const hardwareName = profile.hardwarename;
const hardwareModel = profile.hardwaremodel;
if (hardwareVendor.hasValue &&
hardwareName.hasValue &&
hardwareModel.hasValue) {
message += `\r\n\t${hardwareVendor.value} ` +
`${hardwareName.value.join(',')} (${hardwareModel.value})`;
} else {
message += `\r\n\t${hardwareVendor.noValueMessage}`;
}
});
console.log(message);
};
const nativeModeliOS = 'iPhone11,8';
const nativeModelAndroid = 'SC-03L';
outputDetails(nativeModeliOS);
outputDetails(nativeModelAndroid);
}