전방 js IOS 장치 모델 식별
                                            
 3460 단어  작업 노트
                    
(function () {
    var canvas, gl, glRenderer, models,
        devices = {
            "Apple A7 GPU": {
                1136: ["iPhone 5", "iPhone 5s"],
                2048: ["iPad Air", "iPad Mini 2", "iPad Mini 3"]
            },
            "Apple A8 GPU": {
                1334: ["iPhone 6"],
                2208: ["iPhone 6 Plus"],
                2048: ["iPad Air 2", "iPad Mini 4"]
            },
            "Apple A9 GPU": {
                1136: ["iPhone SE"],
                1334: ["iPhone 6s"],
                2208: ["iPhone 6s Plus"],
            },
            "Apple A10 GPU": {
                1334: ["iPhone 7"],
                2208: ["iPhone 7 Plus"]
            },
            "Apple A11 GPU": {
                1334: ["iPhone 8"],
                2208: ["iPhone 8 Plus"],
                2436: ["iPhone X"],
            },
            "Apple A12 GPU": {
                2436: ["iPhone XS"],
                2688: ["iPhone XS MAX"],
                1792: ["iphone XR"]
            },
        };
    function getCanvas() {
        if (canvas == null) {
            canvas = document.createElement('canvas');
        }
        return canvas;
    }
    function getGl() {
        if (gl == null) {
            gl = getCanvas().getContext('experimental-webgl');
        }
        return gl;
    }
    function getScreenWidth() {
        // alert(Math.max(screen.width, screen.height) * (window.devicePixelRatio || 1))
        console.log(Math.max(screen.width, screen.height) * (window.devicePixelRatio || 1))
        return Math.max(screen.width, screen.height) * (window.devicePixelRatio || 1);
    }
    function getGlRenderer() {
        if (glRenderer == null) {
            debugInfo = getGl().getExtension('WEBGL_debug_renderer_info');
            glRenderer = debugInfo == null ? 'unknown' : getGl().getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
        }
        console.log(glRenderer);
        return glRenderer;
    }
    function getModels() {
        var userAgent = window.navigator.userAgent;
        //  
        if (userAgent.indexOf('iPhone') === -1) {
            // return 'Android';
            models = ['Android'];
            return models;
        }
        var device = devices[getGlRenderer()];
        if (device == undefined) {
            models = ['unknown'];
        } else {
            models = device[getScreenWidth()];
            if (models == undefined) {
                models = ['unknown'];
            }
        }
        return models;
    }
    function getIphoneVersion() {
        var userAgent = window.navigator.userAgent;
        //  
        if (userAgent.indexOf('iPhone') === -1) {
            return ' !';
        }
        var str = userAgent.toLowerCase(); 
        var version =str.match(/cpu iphone os (.*?) like mac os/);
        return version[1].replace(/_/g,".")
    }
    if (window.MobileDevice == undefined) {
        window.MobileDevice = {};
    }
    window.MobileDevice.getGlRenderer = getGlRenderer;
    window.MobileDevice.getModels = getModels;
    window.MobileDevice.getIphoneVersion = getIphoneVersion;
})();이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[난치병] 시스템 시간이 잘못되어 SSL 연결이 실패했습니다.우리 안드로이드 박스의 클라이언트는 매번 첫 번째 서버에 연결할 때마다 ssl 오류가 발생하여 연결이 실패합니다. SSL_connect error:00000001:lib(0):func(0):reason(1) 네트워크...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.