All Projects → EddyVerbruggen → nativescript-taptic-engine

EddyVerbruggen / nativescript-taptic-engine

Licence: MIT license
📳 Use Apple's Taptic Engine to vibrate your iPhone 6s (and up) in a variety of ways

Programming Languages

Vue
7211 projects
typescript
32286 projects
shell
77523 projects
SCSS
7915 projects

Projects that are alternatives of or similar to nativescript-taptic-engine

nativescript-image-filters
NativeScript plugin to apply filters to images
Stars: ✭ 30 (+87.5%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-printer
📠 Send an image or the screen contents to a physical printer
Stars: ✭ 33 (+106.25%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-http
The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning
Stars: ✭ 32 (+100%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-menu
A plugin that adds a pop-up menu to NativeScript
Stars: ✭ 17 (+6.25%)
Mutual labels:  nativescript, nativescript-plugin
marketplace-feedback
This repository is for feedback regarding NativeScript Marketplace. Use the issues system here to submit feature requests, vote for existing ones or report bugs.
Stars: ✭ 16 (+0%)
Mutual labels:  feedback, nativescript
nativescript-apple-sign-in
Sign In With Apple, as seen on WWDC 2019, available with iOS 13
Stars: ✭ 37 (+131.25%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-ng-shadow
Angular directive to apply shadows to native elements according to the elevation level guidelines of material design specification
Stars: ✭ 54 (+237.5%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-app-shortcuts
👇 Home Icon Actions for your NativeScript app, now also for Android!
Stars: ✭ 45 (+181.25%)
Mutual labels:  nativescript, nativescript-plugin
Nativescript Vue
Native mobile applications using Vue and NativeScript.
Stars: ✭ 4,784 (+29800%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-homekit
🏡 HomeKit plugin for your fancy NativeScript app
Stars: ✭ 23 (+43.75%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-app-icon-changer
Change the homescreen icon of your NativeScript iOS app at runtime!
Stars: ✭ 16 (+0%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-store-update
No description or website provided.
Stars: ✭ 18 (+12.5%)
Mutual labels:  nativescript, nativescript-plugin
ui
Add right-to-left support to the NativeScript framework
Stars: ✭ 22 (+37.5%)
Mutual labels:  nativescript, nativescript-plugin
texttospeech
Text to Speech NativeScript plugin for Android & iOS 📢
Stars: ✭ 44 (+175%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-fabric
Handling App URLs in nativescript apps
Stars: ✭ 29 (+81.25%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-performance-monitor
⚡ Proof your app maintains 60-ish FPS by collecting data or showing it on screen with this NativeScript plugin!
Stars: ✭ 21 (+31.25%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-appversion
🔢 NativeScript plugin to retrieve your app's package ID and current version
Stars: ✭ 47 (+193.75%)
Mutual labels:  nativescript, nativescript-plugin
insomnia
😪 NativeScript plugin to keep the device awake (not dim the screen, lock, etc)
Stars: ✭ 40 (+150%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-vue-multi-drawer
A NativeScript-Vue component for creating multiple side drawers (4 sides supported)
Stars: ✭ 45 (+181.25%)
Mutual labels:  nativescript, nativescript-plugin
Nativescript Feedback
📢 Non-blocking textual feedback for your NativeScript app
Stars: ✭ 127 (+693.75%)
Mutual labels:  feedback, nativescript

NativeScript Taptic Engine plugin

Build Status NPM version Downloads Twitter Follow

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:

tns plugin add nativescript-taptic-engine

Demo app (NativeScript Core, XML)

Want to dive in quickly? Check out the demo app! Otherwise, continue reading.

You can run the demo app from the root of the project by typing npm run demo.ios.device and you'll see this:

Demo app (NativeScript-Vue)

We also have a Vue demo! Check out the demo-vue app!

To run it locally:

git clone https://github.com/EddyVerbruggen/nativescript-taptic-engine
cd nativescript-taptic-engine/src
npm run demo-vue.ios

Using Angular?

There's nothing that prevents you from using Angular. Just copy the examples in the Vue or Core demo (or the snippets below).

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 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.

The API names are modeled after what Apple has called them:

selection

Use selection feedback generators to indicate a change in selection.

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

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

tapticEngine.selection();
JavaScript
// require the plugin
var TapticEngine = require("nativescript-taptic-engine").TapticEngine;

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

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
// require the plugin
import {TapticEngine, TapticEngineNotificationType} from "nativescript-taptic-engine";

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

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
// 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.

weakBoom

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

TypeScript
// 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
// 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.

Codewise this is exactly the same as weakBoom, except for the function name of course.

burst

This triggers the 'Nope' effect you get when fi. force touching a home icon which doesn't have any action. It's a short burst of 3-ish 'weak booms'.

Codewise this is exactly the same as weakBoom and strongBoom, except for the function name of course.

Changelog

  • 2.1.0 Modernized the code a little, migrated to the plugin seed structure, and added a Vue demo.
  • 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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].