如何添加phonegap蓝牙插件
How to add phonegap bluetooth plugin
我使用 CLI 添加了蓝牙插件,并将以下代码添加到 index.html。但这是行不通的。我是 phonegap 的新手。请帮助包括这个插件。我用过tanelign-bluetooth插件
<script>
window.bluetooth.pair(
function() {
alert('Pairing Successful');
},
function(err) {
alert('There was an error Pairing to a device'+ JSON.stringify(err));
}, deviceaddress);
您需要先在设备就绪事件中添加:
document.addEventListener("deviceready", yourCallbackFunction, false);
function yourCallbackFunction(){
window.bluetooth = cordova.require("cordova/plugin/bluetooth");
}
并在您的页面中添加此 js:
https://github.com/tanelih/phonegap-bluetooth-plugin/tree/master/www
像这样:<script src="bluetooth.js"></script>
我使用 CLI 添加了蓝牙插件,并将以下代码添加到 index.html。但这是行不通的。我是 phonegap 的新手。请帮助包括这个插件。我用过tanelign-bluetooth插件
<script>
window.bluetooth.pair(
function() {
alert('Pairing Successful');
},
function(err) {
alert('There was an error Pairing to a device'+ JSON.stringify(err));
}, deviceaddress);
您需要先在设备就绪事件中添加:
document.addEventListener("deviceready", yourCallbackFunction, false);
function yourCallbackFunction(){
window.bluetooth = cordova.require("cordova/plugin/bluetooth");
}
并在您的页面中添加此 js: https://github.com/tanelih/phonegap-bluetooth-plugin/tree/master/www
像这样:<script src="bluetooth.js"></script>