When using lambda I could either get 'Desktop' or 'Mobile'.
but if I send a Tablet UserAgent, it is not classifying it as Tablet.
Here is the lambda code that i used!
exports.handler = (event, context, callback) => {
var region = process.env.AWS_REGION ? process.env.AWS_REGION : 'us-east-1';
console.log(region);
console.log(event);
var device = {};
if( event.headers['CloudFront-Is-Mobile-Viewer'] === "true" )
device.device = 'Mobile';
else if ( event.headers['CloudFront-Is-Tablet-Viewer'] === "true" )
device.device = 'Tablet';
else
device.device = 'Desktop';
var response = {
statusCode: 200,
body: JSON.stringify(device)
};
callback(null, response);
};
I did double checked the headers received to lambda as well.
'CloudFront-Is-Desktop-Viewer': 'true',
'CloudFront-Is-Mobile-Viewer': 'false',
'CloudFront-Is-SmartTV-Viewer': 'false',
'CloudFront-Is-Tablet-Viewer': 'false',
'CloudFront-Viewer-Country': 'US',