Skip to content

Commit

Permalink
#4 HeadsetDetection.m:9:33: error: no visible @interface for 'CDVPlug…
Browse files Browse the repository at this point in the history
…inResult' declares the selector 'toSuccessCallbackString

#2 plugins.cordova.io will be deprecated in the near future
  • Loading branch information
EddyVerbruggen committed Mar 9, 2016
1 parent 4459bdb commit ace06e3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 50 deletions.
46 changes: 5 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ by [Eddy Verbruggen](http://www.x-services.nl) / [@eddyverbruggen](http://www.tw
1. [Description](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#1-description)
2. [Installation](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#2-installation)
2. [Automatically (CLI / Plugman)](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#automatically-cli--plugman)
2. [Manually](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#manually)
2. [PhoneGap Build](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#phonegap-build)
3. [Usage](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#3-usage)
4. [Credits](https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#4-credits)
Expand All @@ -23,54 +22,19 @@ Detect a wired or wireless (Bluetooth) headset, connected to you phone.
### Automatically (CLI / Plugman)
HeadsetDetection is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman) and the PhoneGap and Cordova CLI:

PhoneGap CLI:
```
$ phonegap local plugin add https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin.git
```
Cordova CLI:
```
$ cordova plugin add https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin.git
$ cordova prepare
```

### Manually

1\. Add the following xml to your `config.xml` in the root directory of your `www` folder:
```xml
<!-- for iOS -->
<feature name="HeadsetDetection">
<param name="ios-package" value="HeadsetDetection" />
</feature>
```
```xml
<!-- for Android -->
<feature name="HeadsetDetection">
<param name="android-package" value="nl.xservices.plugins.HeadsetDetection" />
</feature>
```

2\. Grab a copy of HeadsetDetection.js, add it to your project and reference it in `index.html`:
```html
<script type="text/javascript" src="js/HeadsetDetection.js"></script>
```

3\. Download the source files for iOS and/or Android and copy them to your project.

iOS: Copy `HeadsetDetection.h` and `HeadsetDetection.m` to `platforms/ios/<ProjectName>/Plugins`

Android: Copy `HeadsetDetection.java` to `platforms/android/src/nl/xservices/plugins` (create the folders)

4\. For most Android devices you need to add a permission to `AndroidManifest.xml`:
```xml
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
$ cordova plugin add cordova-plugin-headsetdetection
$ cordova prepare
```

### PhoneGap Build

HeadsetDetection will soon work with PhoneGap build too (submitted for review on April 8th 2014).
Just add the following xml to your `config.xml` to always use the latest version of this plugin:
HeadsetDetection works with PhoneGap build too, just add the following xml to your `config.xml` to always use the latest version of this plugin:

```xml
<gap:plugin name="nl.x-services.plugins.headsetdetection" />
<plugin name="cordova-plugin-headsetdetection" source="npm"/>
```

The required javascript file is brought in automatically. There is no need to change or add anything in your html.
Expand Down
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "cordova-plugin-headsetdetection",
"version": "2.0.0",
"description": "Detect a wired or Bluetooth headset",
"cordova": {
"id": "cordova-plugin-headsetdetection",
"platforms": [
"ios",
"android"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin.git"
},
"keywords": [
"cordova",
"bluetooth",
"headset",
"headset detection",
"ecosystem:cordova",
"cordova-ios",
"cordova-android"
],
"author": "Eddy Verbruggen <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin/issues"
},
"homepage": "https://github.com/EddyVerbruggen/HeadsetDetection-PhoneGap-Plugin#readme"
}
8 changes: 3 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="nl.x-services.plugins.headsetdetection"
version="1.0">
id="cordova-plugin-headsetdetection"
version="2.0.0">

<name>Headset Detection</name>

<description>
Detect a wired or Bluetooth headset.
</description>
<description>Detect a wired or Bluetooth headset</description>

<license>MIT</license>

Expand Down
6 changes: 2 additions & 4 deletions src/ios/HeadsetDetection.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#import "HeadsetDetection.h"
#import <Cordova/CDV.h>

@implementation HeadsetDetection

- (void) detect:(CDVInvokedUrlCommand*)command {
NSString *callbackId = command.callbackId;
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:[self isHeadsetEnabled]];
[self writeJavascript:[result toSuccessCallbackString:callbackId]];
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:[self isHeadsetEnabled]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (BOOL) isHeadsetEnabled {
Expand Down

0 comments on commit ace06e3

Please sign in to comment.