# react-native-pinch-encoded

> React Native fetch with SSL Pinning support

Latest version **0.0.44** (published 2017-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-pinch-encoded
pnpm add react-native-pinch-encoded
yarn add react-native-pinch-encoded
bun add react-native-pinch-encoded
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.44 |
| Published | 2017-12-06 |
| First published | 2017-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Localz |
| Maintainers | redant |
| Keywords | react-native, ios, android, SSL, Network |

## Links

- npm: https://www.npmjs.com/package/react-native-pinch-encoded
- Repository: https://github.com/jahans3/react-native-pinch
- Homepage: https://github.com/jahans3/react-native-pinch#readme
- Issues: https://github.com/jahans3/react-native-pinch/issues
- npm.io page: https://npm.io/package/react-native-pinch-encoded

## Dependencies (1)

- [q](https://npm.io/package/q.md) ^1.4.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.44 (latest) — 2017-12-06
- 0.0.43 — 2017-12-05
- 0.0.42 — 2017-10-03
- 0.0.41955 — 2017-10-03
- 0.0.41954 — 2017-10-03
- 0.0.41953 — 2017-10-03
- 0.0.41952 — 2017-10-03
- 0.0.41951 — 2017-10-03
- 0.0.4195 — 2017-10-03
- 0.0.419 — 2017-10-03
- 0.0.4185 — 2017-10-03
- 0.0.418 — 2017-10-03
- 0.0.4175 — 2017-10-03
- 0.0.417 — 2017-10-03
- 0.0.4165 — 2017-10-03
- … 27 more at https://npm.io/package/react-native-pinch-encoded/versions

## README

# Pinch 👌

This is a fork of `react-native-pinch`, the only difference is it decodes responses with NSIOSLatin1StringEncoding rather than NSUTF8Encoding as this was causing app crashes. PR sent to main repo.

Callback and promise based HTTP client that supports SSL pinning for React Native.

## Installation

Using NPM:
```
npm install react-native-pinch
```

Using Yarn:
```
yarn add react-native-pinch
```

## Automatically link

#### With React Native 0.27+

```shell
react-native link react-native-pinch
```

#### With older versions of React Native

You need [`rnpm`](https://github.com/rnpm/rnpm) (`npm install -g rnpm`)

```shell
rnpm link react-native-pinch
```

## Manually link

### iOS (via Cocoa Pods)
Add the following line to your build targets in your `Podfile`

`pod 'RNPinch', :path => '../node_modules/react-native-pinch'`

Then run `pod install`

### Android

- in `android/app/build.gradle`:

```diff
dependencies {
    ...
    compile "com.facebook.react:react-native:+"  // From node_modules
+   compile project(':react-native-pinch')
}
```

- in `android/settings.gradle`:

```diff
...
include ':app'
+ include ':react-native-pinch'
+ project(':react-native-pinch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pinch/android')
```

#### With React Native 0.29+

- in `MainApplication.java`:

```diff
+ import com.localz.PinchPackage;

  public class MainApplication extends Application implements ReactApplication {
    //......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+         new PinchPackage(),
          new MainReactPackage()
      );
    }

    ......
  }
```

#### With older versions of React Native:

- in `MainActivity.java`:

```diff
+ import com.localz.PinchPackage;

  public class MainActivity extends ReactActivity {
    ......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+       new PinchPackage(),
        new MainReactPackage()
      );
    }
  }
```

## Adding certificates

Before you can make requests using SSL pinning, you first need to add your `.cer` files to your project's assets.

### Android

 - Place your `.cer` files under `src/main/assets/`.

### iOS

 - Place your `.cer` files in your iOS Project. Don't forget to add them in your `Build Phases > Copy Bundle Resources`, in Xcode.


## Example
*Examples are using the ES6 standard*

Requests can be made by using the `fetch(url[, config, [callback]])` method of Pinch.

### Using Promises
```javascript
import pinch from 'react-native-pinch';

pinch.fetch('https://my-api.com/v1/endpoint', {
  method: 'post',
  headers: { customHeader: 'customValue' },
  body: '{"firstName": "Jake", "lastName": "Moxey"}',
  sslPinning: {
    cert: 'my-cool-cert'
  }
})
  .then(res => console.log(`We got your response! Response - ${res}`))
  .catch(err => console.log(`Whoopsy doodle! Error - ${err}`))
```

### Using Callbacks
```javascript
import pinch from 'react-native-pinch';

pinch.fetch('https://my-api.com/v1/endpoint', {
  method: 'post',
  headers: { customHeader: 'customValue' },
  body: '{"firstName": "Jake", "lastName": "Moxey"}',
  timeoutInterval: 10000 // timeout after 10 seconds
  sslPinning: {
    cert: 'my-cool-cert'
  }
}, (err, res) => {
  if (err) {
    console.error(`Whoopsy doodle! Error - ${err}`);
    return null;
  }
  console.log(`We got your response! Response - ${res}`);
})
```

## Response Schema
```javascript
{
  bodyString: '',

  headers: {},

  status: 200,

  statusText: 'OK'
}
```

---
_Source: https://npm.io/package/react-native-pinch-encoded · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
