2017-08-02 50 views

回答

1

最後navigator.permissions.query會支持這個。來自Web Bluetooth Specification的示例代碼

navigator.permissions.query({ 
    name: "bluetooth", 
    deviceId: sessionStorage.lastDevice, 
}).then(result => { 
    if (result.devices.length == 1) { 
    return result.devices[0]; 
    } else { 
    throw new DOMException("Lost permission", "NotFoundError"); 
    } 
}).then(...); 

但是,no browser currently implements this

Q3 2017開始,鉻的實現在積極地處理Web藍牙,但沒有這個功能。