<commit_before># 3D Touch Cordova plugin
by [<NAME>](http://twitter.com/eddyverbruggen)

## 0. Index

1. [Description](#1-description)
2. [Screenshots](#2-screenshots)
3. [Installation](#3-installation)
4. [Usage](#4-usage)
5. [Changelog](#5-changelog)

## 1. Description

Add 3D Touch capabilities to your Cordova app:
* Quick Action for Home Screen icons
* Enable Link preview for external links

## 2. Screenshots

<img src="screenshots/icon-actions-2.PNG" width="235"/>&nbsp;
<img src="screenshots/icon-actions-4.PNG" width="235"/>&nbsp;
<img src="screenshots/link-preview.PNG" width="235"/>&nbsp;

## 3. Installation

Latest stable version from npm:
```
$ cordova plugin add cordova-plugin-3dtouch
```

Bleeding edge version from Github:
```
$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-3dtouch
```

`ThreeDeeTouch.js` is brought in automatically.
It adds a global `ThreeDeeTouch` object which you can use to interact with the plugin.

## 4. Usage

Check the [demo code](demo/index.html) for all the tricks in the book!

Make sure to wait for `deviceready` before using any of these functions.

Note that all these functions have optional callbacks, but mostly they're irrelevant,
except for the first function here:

### isAvailable
You need an iPhone 6S or some future tech to use the features of this plugin,
so you can check at runtime if the user's device is supported.

```js
  ThreeDeeTouch.isAvailable(function (avail) {
    // 'avail' is a boolean
    alert("avail? " + avail)
  });
```

### configureQuickActions
When your app starts you can add those fancy Quick Actions to the Home Screen icon.
You can configure up to four icons and they are 'cached' until you pass in a new set of icons.
So you don't need to do this every time your app loads, but it can't really hurt.

There are two types of icons supported currently" `iconType` and `iconTemplate`. The former is a fixed list
of 'compose'/'play'/'pause'/'add'/'location'/'search'/'share' and have been provided by Apple and look great.
The `iconTemplate` can be used to provide your own icon. It must be a valid name of an icon template in
your Assets catalog.

The `type` param is the most convenient way to relate the icon to the event you'll receiver when
the icon was used to launch your app. So make sure it's unique amongst your icons.

```js
  ThreeDeeTouch.configureQuickActions([
    {
      type: 'checkin', // optional, but can be used in the onHomeIconPressed callback
      title: 'Check in', // mandatory
      subtitle: 'Quickly check in', // optional
      iconType: 'compose' // optional
    },
    {
      type: 'share',
      title: 'Share',
      subtitle: 'Share like you care',
      iconType: 'share'
    },
    {
      type: 'search',
      title: 'Search',
      iconType: 'search'<commit_msg>icon type<commit_after># 3D Touch Cordova plugin
by [<NAME>](http://twitter.com/eddyverbruggen)

## 0. Index

1. [Description](#1-description)
2. [Screenshots](#2-screenshots)
3. [Installation](#3-installation)
4. [Usage](#4-usage)
5. [Changelog](#5-changelog)

## 1. Description

Add 3D Touch capabilities to your Cordova app:
* Quick Action for Home Screen icons
* Enable Link preview for external links

## 2. Screenshots

<img src="screenshots/icon-actions-2.PNG" width="235"/>&nbsp;
<img src="screenshots/icon-actions-4.PNG" width="235"/>&nbsp;
<img src="screenshots/link-preview.PNG" width="235"/>&nbsp;

## 3. Installation

Latest stable version from npm:
```
$ cordova plugin add cordova-plugin-3dtouch
```

Bleeding edge version from Github:
```
$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-3dtouch
```

`ThreeDeeTouch.js` is brought in automatically.
It adds a global `ThreeDeeTouch` object which you can use to interact with the plugin.

## 4. Usage

Check the [demo code](demo/index.html) for all the tricks in the book!

Make sure to wait for `deviceready` before using any of these functions.

Note that all these functions have optional callbacks, but mostly they're irrelevant,
except for the first function here:

### isAvailable
You need an iPhone 6S or some future tech to use the features of this plugin,
so you can check at runtime if the user's device is supported.

```js
  ThreeDeeTouch.isAvailable(function (avail) {
    // 'avail' is a boolean
    alert("avail? " + avail)
  });
```

### configureQuickActions
When your app starts you can add those fancy Quick Actions to the Home Screen icon.
You can configure up to four icons and they are 'cached' until you pass in a new set of icons.
So you don't need to do this every time your app loads, but it can't really hurt.

There are two types of icons supported currently" `iconType` and `iconTemplate`. The former is a fixed list
of Compose/Play/Pause/Add/Location/Search/Share/Prohibit/Contact/Home/MarkLocation/Favorite/Love/Cloud/Invitation/Confirmation/Mail/Message/Date/Time/CapturePhoto/CaptureVideo/Task/TaskCompleted/Alarm/Bookmark/Shuffle/Audio/Update and have been provided by Apple and look great.
The `iconTemplate` can be used to provide your own icon. It must be a valid name of an icon template in
your Assets catalog.

The `type` param is the most convenient way to relate the icon to the event you'll receiver when
the icon was used to launch your app. So make sure it's unique amongst your icons.

```js
  ThreeDeeTouch.configureQuickActions([
    {
      type: 'checkin', // optional, but can be used in the onHomeIconPressed callback
      title: 'Check in', // mandatory
      subtitle: 'Quickly check in', // optional
      iconType: 'compose' // optional
    },
    {
      type: 'share',
      title: 'Share',
      subtitle: 'Share like you care',
      iconType: 'share'
    },
    {
      type: 'search',
      title: 'Search',
      iconType: 'search'
{'fraction_non_alphanumeric': 0.10491803278688525, 'fraction_numerical': 0.010698878343399483, 'mean_word_length': 3.89527027027027, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1904374', 'n_tokens_mistral': 1825, 'n_tokens_neox': 1721, 'n_words': 710}