Environment Checker

This package allows you to automatically run the environment check and receive the return the result in a simplified format. We provide three versions of Environment Checker, version 1 should be used for flash-only collections, version 2 for flash and WebRTC collections, version 3 for WebRTC only.

Installation

CDN version

The general format for the script URL is "https://codesdwncdn.realeyesit.com/environment-checker/release/{version}/Realeyesit.EnvironmentalDetectionAPI.min.js". You can specify which kinds of updates your app can accept using semver string in a following format:

  • x.y to receive only bug fixes: https://codesdwncdn.realeyesit.com/environment-checker/release/3.1/Realeyesit.EnvironmentalDetectionAPI.min.js
  • x to receive bug fixes and new features (recommended): https://codesdwncdn.realeyesit.com/environment-checker/release/3/Realeyesit.EnvironmentalDetectionAPI.min.js

This example loads the latest release of version 3:

<script src="https://codesdwncdn.realeyesit.com/environment-checker/release/3/Realeyesit.EnvironmentalDetectionAPI.min.js"></script>

Self hosted

To use the self-hosted solution you will have to download the archive that contains all necessary files and deploy it on your host https://codesdwncdn.realeyesit.com/environment-checker/release/3/environment-checker.zip. You will also have to change the SWF path in the javascript source code. Find the DEFAULT_FLASH_DETECTOR_PATH variable and replace its value, for example DEFAULT_FLASH_DETECTOR_PATH = ‘https://example.com/environment-detector.swf’;

API

To use environment checker you can register a callback function _RealeyesitEnvDetectCallback or _RealeyesitEnvDetectParams._callback. The other way is to call the Realeyesit.EnvironmentalDetectionAPI.start(callback, options) method manually. In this case you should provide the callback that will handle the result. options parameter is optional and can be used to disable logging, for example: Realeyesit.EnvironmentalDetectionAPI.start(callback, { logger: { disable: true } }). In options we can manage the allowed device types also for example: Realeyesit.EnvironmentalDetectionAPI.start(callback, { logger: { disable: true }, allowedDevices: [ 'mobile', 'tablet', 'desktop' ] }) The result will be in the following format:

{
  checksPassed: boolean,
  failureReasonCode: number,
  failureReasonString: string,
  detectorResult: {
          browser: {
            name: string,
            version: string,
          },
          platform: {
            type: string,
          },
          os: {
            name: string,
            version: string,
          },
          flash: ({
            version: string,
          }|null),
          webcams: Array.<string>,
          capabilities: Array.<string>
          },
}

Where ‘failureReasonCode’ is one of:

  • BROWSER_NOT_CAPABLE: 4
  • MOBILE_BROWSER: 5
  • NO_WEBCAMS_DETECTED: 6
  • OTHER_ERROR: 7
  • IOS_WEBVIEW: 8
  • UNSUPPORTED_BROWSER: 9
  • TABLET_BROWSER: 10
  • DESKTOP_BROWSER: 11

And ‘detectorResult’ is a result object of environment detector (see more Environment Detector API)

NOTE: if you are using Environment Checker, then there is no need to use Environment Detector separately.

Example usage

<script type="text/javascript">
    function environmentalDetectionCallback(result) {
        alert(result.checksPassed ? 'Passed ' : 'Failed. ' + result.failureReasonString);
    }
    var _RealeyesitEnvDetectParams = _RealeyesitEnvDetectParams || {};
    _RealeyesitEnvDetectParams._callback = environmentalDetectionCallback;
    (function() {
        var envDetect = document.createElement('script');
        envDetect.type = 'text/javascript';
        envDetect.async = true;
        envDetect.src = 'https://codesdwncdn.realeyesit.com/environment-checker/release/3/Realeyesit.EnvironmentalDetectionAPI.min.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(envDetect, s);
    })();
</script>

License

Copyright 2018 Realeyes OU.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.