I'm trying to notified the user if the mobile that he is using is compatible with augmented reality. I would like to identified if the mobile is compatible and then if its not show a simple notification like: "your mobile is not compatible with AR". I use model-viewer as base.
Can you guys help me?
I tried
if (navigator.xr) {
navigator.xr.isSessionSupported('immersive-ar').then(function (supported) {
if (supported) {
console.log("AR is supported on this device");
} else {
console.log("AR is not supported on this device");
alert("Augmented reality is not supported on this device. Please try using a different device.");
}
});
} else {
console.log("WebXR API is not supported on this device");
alert("WebXR API is not supported on this device. Please try using a different device.");
}
__ This code should will display an alert message using the alert function if the device either does not support the WebXR API or if it does not support the 'immersive-ar' session mode.
But isn't working. It is showing for everyone this message.