nativescript-headset-detection
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

NativeScript Headset Detection plugin

Build Status NPM version Twitter Follow

Installation

tns plugin add nativescript-headset-detection

API

isConnected

To check for a headset at any given moment, use this method:

JavaScript

var headsetDetection = require("nativescript-headset-detection");
 
headsetDetection.isConnected()
    .then(function (connected) { console.log("Connected? " + connected); })
    .catch(function (err) { console.log("Error: " + err)});

TypeScript

import * as headsetDetection from 'nativescript-headset-detection';
 
headsetDetection.isConnected()
    .then(connected => console.log(`Connected? ${connected}`))
    .catch(err => console.log(`Error: ${err}`));

onConnectionStateChanged

To listen to changes to the headset state, use this one (adding it to a high level component like `app.[ts|js] makes sense); you can pass in a callback function that gets invoked whenever a headset is (dis)connected:

JavaScript

var headsetDetection = require("nativescript-headset-detection");
 
headsetDetection.onConnectionStateChanged(function (connected) {
  console.log("Connection changed to: " + connected);
});

TypeScript

import * as headsetDetection from 'nativescript-headset-detection';
 
headsetDetection.onConnectionStateChanged(connected => console.log(`Connection changed to: ${connected}`));

Package Sidebar

Install

npm i nativescript-headset-detection

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

28.9 kB

Total Files

12

Last publish

Collaborators

  • eddyverbruggen