如何添加phonegap蓝牙插件

时间:2015-10-25 08:29:29

标签: android cordova bluetooth

我已经使用CLI添加了蓝牙插件,我将下面的代码添加到index.html。但这不起作用。我是phonegap的新手。请帮助包含此插件。我使用过tanelign-bluetooth插件。

 <ion-nav-back-button class="no-text">
            </ion-nav-back-button>
            <ion-nav-buttons side="right">
                <button class="button button-icon button-clear ion-android-more-vertical" menu-toggle="right">
                </button>
            </ion-nav-buttons>
        </ion-nav-bar>
        <ion-nav-view name="fabContent"></ion-nav-view>
        <ion-nav-view name="menuContent" ng-class="{expanded: isExpanded}" ></ion-nav-view>
    </ion-side-menu-content>
    <ion-side-menu side="right">
        <ion-header-bar class="dark-bg expanded">
           <span class="avatar" style="background: url('img/crown.jpg'); background-size: cover; "></span> 
            <h2>Thronester</h2>
        </ion-header-bar>

1 个答案:

答案 0 :(得分:1)

您需要先在设备就绪事件中添加此内容:

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>

文档:https://github.com/tanelih/phonegap-bluetooth-plugin