
# react-native-redirapp
Just an React-Native wrapper for Redirapp (if you need to use more functions than only *init*).

## Getting started

`$ npm install react-native-redirapp --save`

## Before continue (iOS only)
If you wanna use this lib with iOS, you need to change your Podfile. This is necessary because Redirapp is served via Cocoapods.
**If you know another way to link Redirapp (using Cocoapods), please open an issue or just send a PR.**

### Steps for Cocoapods
At your **YourProject/ios/Podfile** file, you need to point RNRedirapp as an additional pod (or something like this):

```ruby
platform :ios, '9.0'
use_frameworks!
workspace 'YourProject.xcworkspace'

target 'YourProject' do
    pod 'Redirapp', '0.0.6'

    target 'RNRedirapp' do
        project '../node_modules/react-native-redirapp/ios/RNRedirapp.xcodeproj'
        inherit! :search_paths
    end
end

```

Your project structure will be a little ugly. Be advised.


### Mostly automatic installation

`$ react-native link react-native-redirapp`


### Manual installation


#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [YourProject]`
2. Go to `node_modules` ➜ `react-native-redirapp` and add `RNRedirapp.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNRedirapp.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`).

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
  - Add `import com.kytepos.rn.redirapp.RNRedirappPackage;` to the imports at the top of the file
  - Add `new RNRedirappPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-redirapp'
  	project(':react-native-redirapp').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-redirapp/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':react-native-redirapp')
  	```


## Usage
```javascript
import { RNRedirapp } from 'react-native-redirapp';

initRedirapp() {
	RNRedirapp.init("Your Redirapp Token");
}

logPurchase() {
	RNRedirap.logPurchase('88.77', 'com.product');
}

logPurchaseWithCurrency() {
	RNRedirap.logPurchase('BRL', '88.77', 'com.product');
}
```
