1.0.2 • Published 5 years ago

react-native-redirapp v1.0.2

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
5 years ago

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):

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 LibrariesAdd Files to [YourProject]
  2. Go to node_modulesreact-native-redirapp and add RNRedirapp.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNRedirapp.a to your project's Build PhasesLink 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
  1. 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')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-redirapp')

Usage

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');
}