Gene Z. Ragan
Gene Z. Ragan

Reputation: 2873

Detecting ARKit compatible device from user agent

We would like to enable a feature that allows a model to be viewed using a deep link to our ARKit app from a web page.

Has anyone discovered a way to discover if a device is ARKit compatible using the user agent string or any other browser-based mechanism?

Thanks!

Upvotes: 0

Views: 651

Answers (2)

Kevin Grabher
Kevin Grabher

Reputation: 399

Apple seems to use the following code to show/hide the "Visit this page on iOS 12 to try AR Quick Look" on https://developer.apple.com/arkit/gallery/

(function () {
    var isRelAR = false;
    var a = document.createElement('a');
    if (a.relList.supports('ar')) {
        isRelAR = true;
    }
    document.documentElement.classList.add(isRelAR ? 'relar' : 'no-relar');
})();

The interesting part of course being

    var isRelAR = false;
    var a = document.createElement('a');
    if (a.relList.supports('ar')) {
        isRelAR = true;
    }

Make your actions accordingly based on the value of isRelAR.

Upvotes: 4

rickster
rickster

Reputation: 126177

Safari doesn’t expose any of the required hardware information for that.

If you already have a companion iOS app for your website, another option might be to still provide some non-AR experience for your content, so that the website has something to link to in all cases.

For example, AR furniture catalogs seem to be a thing now. But if the device isn’t ARKit capable, you could still provide a 3D model of each furniture piece linked from your website, letting the user spin it around and zoom in on it with touch gestures instead of placing it in AR.

Upvotes: 2

Related Questions