IsARSupportedOnDevice
We provide a helpful utility module isARSupportedOnDevice to enable our developers to check their app users' device for compatibility to support their AR experiences conditionally. This way app developers can check and render appropriate views depending on whether the device is supported by the underlying AR system.
async isARSupportedOnDevice()
Example Use:
To take advantage of this utility, simply import ViroUtils on top of your scene and create an alias to the function like below:
Android, 3.2.0+: an app built without the
ARxRMode (for examplexRMode: "QUEST"only) leaves ARCore out, and the native check reportsUNSUPPORTED, so the promise rejects with an error whose message isUNSUPPORTED. See Integrating ViroReact with Expo.
Web, 3.2.2+:
isARSupportedOnDeviceanswers from what the browser offers: a secure context (HTTPS), a camera API and motion events. Whether the device has a motion sensor is only known once events arrive, so a desktop browser can pass this check and then report missing motion when AR starts (seeonMotionUnavailable).
import { ViroUtils } from '@reactvision/react-viro';
try {
const result = await isARSupportedOnDevice();
console.log(result.isARSupported);
} catch (err) {
console.error(err);
}
Updated 5 days ago