1.0.2 • Published 5 years ago
react-native-redirapp v1.0.2
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
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [YourProject]
- Go to
node_modules
➜react-native-redirapp
and addRNRedirapp.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNRedirapp.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
).
Android
- 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 thegetPackages()
method
- 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')
- 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');
}