Skip to content

Commit

Permalink
doc++
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Sep 23, 2016
1 parent f45d3d2 commit c716678
Showing 1 changed file with 93 additions and 22 deletions.
115 changes: 93 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# NativeScript Taptic Engine plugin

> __BEWARE__ This plugin uses an undocumented feature which may get your app rejected when reviewed by Apple. Once Apple releases an official API this plugin will be updated of course. [People have used this approach __without problems__ though.](http://stackoverflow.com/questions/32526868/taptic-in-ios-9)

<img src="https://raw.githubusercontent.com/EddyVerbruggen/nativescript-taptic-engine/master/taptic-6s-plus.jpg" width="541px" height="350px"/>

### Supported platforms
* iPhone 6s / 6s Plus or newer
## Supported platforms
* Official API: iPhone 7 / 7 Plus or newer
* Unofficial API: iPhone 6s / 6s Plus or newer
* Requires Xcode 8 to build

## Installation
From the command prompt go to your app's root folder and execute:
Expand All @@ -23,10 +22,27 @@ You can run the demo app from the root of the project by typing `npm run demo.io
<img src="https://raw.githubusercontent.com/EddyVerbruggen/nativescript-taptic-engine/master/demo-app.png" width="375px"/>


## API
## Official API (requires at least iPhone 7)
It's recommended to use this API, but you're limited to iPhone 7 and higher.
As per [Apples guidelines](https://developer.apple.com/reference/uikit/uifeedbackgenerator)
there's no runtime way to determine if the device is capable of providing haptic feedback,
so the Promise can largely be ignored so I'm not even showing them here.

### `weakBoom`
This triggers the same effect as the 'Peek' in 'Peek & Pop', a very brief vibration.
The API names are modeled after what [Apple has called them](https://developer.apple.com/reference/uikit/uifeedbackgenerator):

### `selection`
Use selection feedback generators to indicate a change in selection.

##### TypeScript
```js
// require the plugin
import {TapticEngine} from "nativescript-taptic-engine";

// instantiate the plugin
let tapticEngine = new TapticEngine();

tapticEngine.selection();
```

##### JavaScript
```js
Expand All @@ -36,31 +52,88 @@ var TapticEngine = require("nativescript-taptic-engine").TapticEngine;
// instantiate the plugin
var tapticEngine = new TapticEngine();

tapticEngine.weakBoom().then(
function() {
// note that unsupported iOS devices like the simulator also end up here
console.log("Boomed weakly, if available.");
}, function () {
console.log("You're running on Android. Meh.");
}
);
tapticEngine.selection();
```

### `notification`
Use notification feedback generators to indicate successes, failures, and warnings.

There are 3 notification types: `TapticEngineNotificationType.SUCCESS` (default), `.WARNING`, and `.ERROR`.

##### TypeScript
```js
// require the plugin
import {TapticEngine} from "nativescript-taptic-engine";
import {TapticEngine, TapticEngineNotificationType} from "nativescript-taptic-engine";

// instantiate the plugin
let tapticEngine = new TapticEngine();

tapticEngine.weakBoom().then(() => {
tapticEngine.notification({
type: TapticEngineNotificationType.ERROR
});
```

### `impact`
Use impact feedback generators to indicate that an impact has occurred.
For example, you might trigger impact feedback when a user interface object
collides with something or snaps into place.

There are 3 impact styles: `TapticEngineImpactStyle.LIGHT`, `.MEDIUM` (default), and `.HEAVY`.

##### TypeScript
```js
// require the plugin
import {TapticEngine, TapticEngineImpactStyle} from "nativescript-taptic-engine";

// instantiate the plugin
let tapticEngine = new TapticEngine();

tapticEngine.impact({
type: TapticEngineImpactStyle.HEAVY
});
```


## Unofficial API (requires at least iPhone 6s)
__BEWARE__ This uses an undocumented feature which may get your app rejected when reviewed by Apple.
[People have used this approach __without problems__ though.](http://stackoverflow.com/questions/32526868/taptic-in-ios-9)

### `weakBoom`
This triggers the same effect as the 'Peek' in 'Peek & Pop', a very brief vibration.

##### TypeScript
```js
// require the plugin
import {TapticEngineUnofficial} from "nativescript-taptic-engine";

// instantiate the plugin
let tapticEngineUnofficial = new TapticEngineUnofficial();

tapticEngineUnofficial.weakBoom().then(() => {
// note that unsupported iOS devices like the simulator also end up here
}, (err) => {
console.log("You're running on Android. Meh.");
});
```

##### JavaScript
```js
// require the plugin
var TapticEngineUnofficial = require("nativescript-taptic-engine").TapticEngineUnofficial;

// instantiate the plugin
var tapticEngineUnofficial = new TapticEngineUnofficial();

tapticEngineUnofficial.weakBoom().then(
function() {
// note that unsupported iOS devices like the simulator also end up here
console.log("Boomed weakly, if available.");
}, function () {
console.log("You're running on Android. Meh.");
}
);
```

### `strongBoom`
This triggers the 'Pop' effect of 'Peek & Pop', which is a bit more profound than the 'Peek' effect.

Expand All @@ -73,7 +146,5 @@ This triggers the 'Nope' effect you get when fi. force touching a home icon whic
Codewise this is exactly the same as `weakBoom` and `strongBoom`, except for the function name of course.

## Changelog
* 1.0.0 Initial release

## Future work
* Implement the official API. If any. Ever.
* 2.0.0 Added official API for iPhone 7. Moved the old API to TapticEngineUnofficial.*. Requires Xcode 8 to build.
* 1.0.0 Initial release, unofficial API only. Compatible with any Xcode version.

0 comments on commit c716678

Please sign in to comment.