Skip to content

Commit 9b367b2

Browse files
committed
Publish version 1.2.7
0 parents  commit 9b367b2

12 files changed

+693
-0
lines changed

.gitattributes

Whitespace-only changes.

.gitignore

+399
Large diffs are not rendered by default.

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## 1.2.7 (27 Apr, 2021)
4+
#### Android
5+
- Update native library to 1.2.5
6+
7+
## 1.2.4-alpha01 (26 Apr, 2021)
8+
#### Android
9+
- Update native library to 1.2.2

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# TapsellPlusSDK-ReactNativePlugin [![npm version](https://img.shields.io/npm/v/react-native-tapsell-plus?color=green&label=react-native-tapsell-plus&logo=react)](https://www.npmjs.com/package/react-native-tapsell-plus)
2+
3+
# react-native-tapsell-plus
4+
5+
## Getting started
6+
7+
`$ npm install react-native-tapsell-plus --save`
8+
9+
10+
> If your react-native version is below `0.60`, you need to link it as well:
11+
>
12+
> ```
13+
> $ react-native link react-native-tapsell-plus
14+
> ```
15+
16+
17+
<details>
18+
<summary>Manual installation (Older react native versions)</summary>
19+
20+
#### Android
21+
22+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
23+
- Add `import com.reactlibrary.RNTapsellPlusPackage;` to the imports at the top of the file
24+
- Add `new RNTapsellPlusPackage()` to the list returned by the `getPackages()` method
25+
2. Append the following lines to `android/settings.gradle`:
26+
```
27+
include ':react-native-tapsell-plus'
28+
project(':react-native-tapsell-plus').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-tapsell-plus/android')
29+
```
30+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
31+
```
32+
compile project(':react-native-tapsell-plus')
33+
```
34+
35+
</details>
36+
37+
38+
39+
## Usage
40+
```javascript
41+
import RNTapsellPlus from 'react-native-tapsell-plus';
42+
43+
// TODO: What to do with the module?
44+
RNTapsellPlus;
45+
```
46+

android/build.gradle

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
buildscript {
3+
repositories {
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.3.1'
9+
}
10+
}
11+
12+
apply plugin: 'com.android.library'
13+
14+
android {
15+
compileSdkVersion 29
16+
buildToolsVersion "29.0.2"
17+
18+
defaultConfig {
19+
minSdkVersion 16
20+
targetSdkVersion 29
21+
versionCode 1
22+
versionName "1.0"
23+
}
24+
lintOptions {
25+
abortOnError false
26+
}
27+
}
28+
29+
rootProject.allprojects {
30+
repositories {
31+
mavenCentral()
32+
maven { url 'https://dl.bintray.com/tapsellorg/maven' }
33+
}
34+
}
35+
36+
dependencies {
37+
//noinspection GradleDynamicVersion
38+
implementation 'com.facebook.react:react-native:+'
39+
implementation 'ir.tapsell.plus:tapsell-plus-sdk-reactnative:1.2.5'
40+
}
41+

android/src/main/AndroidManifest.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="ir.tapsell.plus">
4+
5+
</manifest>
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package ir.tapsell.plus;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.bridge.NativeModule;
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
import com.facebook.react.uimanager.ViewManager;
12+
import com.facebook.react.bridge.JavaScriptModule;
13+
14+
public class RNTapsellPlusPackage implements ReactPackage, NoProguard {
15+
@Override
16+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
17+
return Arrays.<NativeModule>asList(new RNTapsellPlusModule(reactContext));
18+
}
19+
20+
// Deprecated from RN 0.47
21+
public List<Class<? extends JavaScriptModule>> createJSModules() {
22+
return Collections.emptyList();
23+
}
24+
25+
@Override
26+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
27+
return Collections.emptyList();
28+
}
29+
}

index.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let TapsellPlusUtils = require("./src/tapsellPlusUtils.js");
2+
3+
module.exports = {
4+
initialize: TapsellPlusUtils.initialize,
5+
setDebugMode: TapsellPlusUtils.setDebugMode,
6+
addFacebookTestDevice: TapsellPlusUtils.addFacebookTestDevice,
7+
requestRewarded: TapsellPlusUtils.requestRewarded,
8+
requestInterstitial: TapsellPlusUtils.requestInterstitial,
9+
requestNative: TapsellPlusUtils.requestNative,
10+
showAd: TapsellPlusUtils.showAd,
11+
nativeAdClicked: TapsellPlusUtils.nativeAdClicked
12+
};

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "react-native-tapsell-plus",
3+
"version": "1.2.7",
4+
"description": "TapsellPlus React native plugin.",
5+
"files": [
6+
"android",
7+
"src",
8+
"package.json",
9+
"README.md"
10+
],
11+
"main": "index.js",
12+
"scripts": {
13+
"test": "echo \"No test to pass. Ignoring\""
14+
},
15+
"keywords": [
16+
"react-native",
17+
"tapsell",
18+
"ad"
19+
],
20+
"author": "Tapsell",
21+
"license": "Apache 2.0",
22+
"peerDependencies": {
23+
"react-native": "0.63.4"
24+
},
25+
"repository": {
26+
"type": "git",
27+
"url": "git+https://github.com/tapsellorg/TapsellPlusSDK-ReactNativePlugin.git"
28+
},
29+
"bugs": {
30+
"url": "https://github.com/tapsellorg/TapsellPlusSDK-ReactNativePlugin/issues"
31+
},
32+
"homepage": "https://github.com/tapsellorg/TapsellPlusSDK-ReactNativePlugin"
33+
}

src/constants.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let TapsellPlusNativeModule = require("react-native").NativeModules.RNTapsellPlus;
2+
3+
module.exports = {
4+
ON_RESPONSE_EVENT: TapsellPlusNativeModule.ON_RESPONSE_EVENT,
5+
ON_NATIVE_RESPONSE_EVENT: TapsellPlusNativeModule.ON_NATIVE_RESPONSE_EVENT,
6+
ON_ERROR_EVENT: TapsellPlusNativeModule.ON_ERROR_EVENT,
7+
8+
ON_OPENED_EVENT: TapsellPlusNativeModule.ON_OPENED_EVENT,
9+
ON_CLOSED_EVENT: TapsellPlusNativeModule.ON_CLOSED_EVENT,
10+
ON_REWARDED_EVENT: TapsellPlusNativeModule.ON_REWARDED_EVENT,
11+
ON_SHOW_ERROR_EVENT: TapsellPlusNativeModule.ON_SHOW_ERROR_EVENT,
12+
13+
ON_RESPONSE_NATIVE_EVENT: TapsellPlusNativeModule.ON_RESPONSE_NATIVE_EVENT,
14+
ON_ERROR_NATIVE_EVENT: TapsellPlusNativeModule.ON_ERROR_NATIVE_EVENT,
15+
};

src/tapsellPlusUtils.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { DeviceEventEmitter } from "react-native";
2+
import Constants from "./constants";
3+
let TapsellPlusNativeModule = require("react-native").NativeModules
4+
.RNTapsellPlus;
5+
6+
let callbacks = {};
7+
8+
callbacks[Constants.ON_RESPONSE_EVENT] = {};
9+
callbacks[Constants.ON_NATIVE_RESPONSE_EVENT] = {};
10+
callbacks[Constants.ON_ERROR_EVENT] = {};
11+
12+
callbacks[Constants.ON_OPENED_EVENT] = {};
13+
callbacks[Constants.ON_CLOSED_EVENT] = {};
14+
callbacks[Constants.ON_REWARDED_EVENT] = {};
15+
callbacks[Constants.ON_SHOW_ERROR_EVENT] = {};
16+
17+
const appEventEmitter = DeviceEventEmitter;
18+
19+
appEventEmitter.addListener(Constants.ON_RESPONSE_EVENT, event => {
20+
if (callbacks[Constants.ON_RESPONSE_EVENT][event.zone_id])
21+
callbacks[Constants.ON_RESPONSE_EVENT][event.zone_id]();
22+
});
23+
24+
appEventEmitter.addListener(Constants.ON_NATIVE_RESPONSE_EVENT, event => {
25+
if (callbacks[Constants.ON_NATIVE_RESPONSE_EVENT][event.zone_id])
26+
callbacks[Constants.ON_NATIVE_RESPONSE_EVENT][event.zone_id](event);
27+
});
28+
29+
appEventEmitter.addListener(Constants.ON_ERROR_EVENT, event => {
30+
if (callbacks[Constants.ON_ERROR_EVENT][event.zone_id])
31+
callbacks[Constants.ON_ERROR_EVENT][event.zone_id](event.error_message);
32+
});
33+
34+
appEventEmitter.addListener(Constants.ON_OPENED_EVENT, event => {
35+
if (callbacks[Constants.ON_OPENED_EVENT][event.zone_id])
36+
callbacks[Constants.ON_OPENED_EVENT][event.zone_id]();
37+
});
38+
39+
appEventEmitter.addListener(Constants.ON_CLOSED_EVENT, event => {
40+
if (callbacks[Constants.ON_CLOSED_EVENT][event.zone_id])
41+
callbacks[Constants.ON_CLOSED_EVENT][event.zone_id]();
42+
});
43+
44+
appEventEmitter.addListener(Constants.ON_REWARDED_EVENT, event => {
45+
if (callbacks[Constants.ON_REWARDED_EVENT][event.zone_id])
46+
callbacks[Constants.ON_REWARDED_EVENT][event.zone_id]();
47+
});
48+
49+
appEventEmitter.addListener(Constants.ON_SHOW_ERROR_EVENT, event => {
50+
if (callbacks[Constants.ON_SHOW_ERROR_EVENT][event.zone_id])
51+
callbacks[Constants.ON_SHOW_ERROR_EVENT][event.zone_id](
52+
event.error_message
53+
);
54+
});
55+
56+
module.exports = {
57+
initialize: function(appKey) {
58+
TapsellPlusNativeModule.initialize(appKey);
59+
},
60+
61+
setDebugMode: function(logLevel) {
62+
TapsellPlusNativeModule.setDebugMode(logLevel);
63+
},
64+
65+
addFacebookTestDevice: function(hash) {
66+
TapsellPlusNativeModule.addFacebookTestDevice(hash);
67+
},
68+
69+
requestRewarded: function(zoneId, onResponse, onError) {
70+
callbacks[Constants.ON_RESPONSE_EVENT][zoneId] = onResponse;
71+
callbacks[Constants.ON_ERROR_EVENT][zoneId] = onError;
72+
TapsellPlusNativeModule.requestRewarded(zoneId);
73+
},
74+
75+
requestInterstitial: function(zoneId, onResponse, onError) {
76+
callbacks[Constants.ON_RESPONSE_EVENT][zoneId] = onResponse;
77+
callbacks[Constants.ON_ERROR_EVENT][zoneId] = onError;
78+
TapsellPlusNativeModule.requestInterstitial(zoneId);
79+
},
80+
81+
requestNative: function(zoneId, onResponse, onError) {
82+
callbacks[Constants.ON_NATIVE_RESPONSE_EVENT][zoneId] = onResponse;
83+
callbacks[Constants.ON_SHOW_ERROR_EVENT][zoneId] = onError;
84+
TapsellPlusNativeModule.requestNative(zoneId);
85+
},
86+
87+
showAd: function(zoneId, onOpened, onClosed, onRewarded, onError) {
88+
callbacks[Constants.ON_OPENED_EVENT][zoneId] = onOpened;
89+
callbacks[Constants.ON_CLOSED_EVENT][zoneId] = onClosed;
90+
callbacks[Constants.ON_REWARDED_EVENT][zoneId] = onRewarded;
91+
callbacks[Constants.ON_ERROR_EVENT][zoneId] = onError;
92+
TapsellPlusNativeModule.showAd(zoneId);
93+
},
94+
95+
nativeAdClicked: function(zoneId, adId) {
96+
TapsellPlusNativeModule.nativeAdClicked(zoneId, adId);
97+
}
98+
};

0 commit comments

Comments
 (0)