npm package: @flyshot/rn-sdk-wrapper
Description: React Native bridge for Flyshot SDK
Author: Samusevich Alexander
Latest version: 0.1.5
Deprecated: this package has been deprecated

# rn-sdk-wrapper
React Native wrapper for Flyshot SDK. Based on [IOS Flyshot SDK](https://bitbucket.org/flyshot/ios-sdk)

# Installation Guide

1. [Install Flyshot SDK for iOS](https://bitbucket.org/flyshot/ios-sdk) via cocoapods (recommended way). If you are using 0.60+ version of React Native read [this](https://github.com/facebook/react-native/issues/25349) and [this](https://github.com/facebook/react-native/issues/25349) before.

1. Install `rn-sdk-wrapper`:

    ```bash
    yarn add @flyshot/rn-sdk-wrapper  # or npm install @flyshot/rn-sdk-wrapper
    ```

1. Link native dependencies

    ```bash
    react-native link @flyshot/rn-sdk-wrapper
    ```

1. Manually Link the library in Xcode ([Linking librarys on iOS](https://facebook.github.io/react-native/docs/linking-libraries-ios.html))

    1. Open Xcode -> Right click "[Your Project Name]/Libraries" folder and select "Add File to [Your Project Name]" -> Select `RNReactNativeFlyshot.xcodeproj` located in `node_modules/@flyshot/rn-sdk-wrapper/ios`.
    1. Open "General Settings" -> "Build Phases" -> "Link Binary with Libraries" and add `libRNReactNativeFlyshot.a`

# Usage

### Import or Require the module

```javascript
import Flyshot from '@flyshot/rn-sdk-wrapper';
```

or

```javascript
var Flyshot = require('@flyshot/rn-sdk-wrapper');
```

### SDK initialization

To initialize SDK call `start` method with token generated in your Flyshot account:

```javascript
const sdkToken = '...';
Flyshot.start(sdkToken);
```

### Public interface

Check user_id session variable. Return true if Flyshot user_id session variable is set:

```javascript
Flyshot.isFlyshotUser((error, result) => {})
```

Check active campaign session variable. Return true if Flyshot active campaign session variable is set:

```javascript
Flyshot.isEligibleForDiscount((error, result) => {})
```

Send Deposit Event to Flyshot Analytics:

```javascript
Flyshot.sendDepositEvent(amount): Promise
```

Send Checkout Event to Flyshot Analytics:

```javascript
Flyshot.sendCheckoutEvent(amount): Promise
```

Send Add To Cart Event to Flyshot Analytics:

```javascript
Flyshot.addToCartEvent(): Promise
```

Send Sign Up Event to Flyshot Analytics:

```javascript
Flyshot.sendSignUpEvent(): Promise
```

Set list of product ids which should not processed:

```javascript
Flyshot.setBlockedPurchasesList(Array<String>): Void
```

### Events

You should use a NativeEmitter to subscribe Flyshot events:

```javascript
import {NativeEventEmitter} from 'react-native';

// ...

const flyshotManagerEmitter = new NativeEventEmitter(Flyshot);

flyshotManagerEmitter.addListener(
    'onFlyshotPurchase',
    (transactions) => {
        /*
         * transactions = [
         *   {
         *      transactionDate: timestamp,
         *      transactionId: string,
         *      productId: string,
         *      transactionState: int,  
         *    },
         *    ...
         * ]
        */
    }
);

flyshotManagerEmitter.addListener(
    'onFlyshotDetectCampaign',
    (productId, deepLink) => {
        // ...
    }
);
```

# Licenses