Bluetooth Serial Problem with ionic

I m trying to build bluetooth application firstly android using latest ionic framework and cordova. I created blank app

but its not working. its causes crash. I cannot find bluetoothserial in ngCordova. someone have exampe with this plugin.
I used this plugin.


my app.js

   // Ionic Starter App

 // angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
 angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
   $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
     // for form inputs)
   if(window.cordova && window.cordova.plugins.Keyboard) {
     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  }
if(window.StatusBar) {
  StatusBar.styleDefault();
}
 });
} ).controller("MainCtrl",function($scope){
    $scope.bluetoothEnable="Test";
    var listPorts = function() {
        // list the available BT ports:
        bluetoothSerial.list(
            function(results) {
              alert(JSON.stringify(results));
            },
            function(error) {
                alert(JSON.stringify(error));
            }
        );
    }

    // if isEnabled returns failure, this function is called:
    var notEnabled = function() {
        alert("Bluetooth is not enabled.")
    }

    // check if Bluetooth is on:
    bluetoothSerial.isEnabled(
        listPorts,
        notEnabled
    );


});

It is on ngCordova just undocumented unfortunately

http://ngcordova.com/build/

1 Like

thank you man .I will try :smile: