tapjoy-react-native-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -0
- package/README.md +67 -0
- package/android/build.gradle +92 -0
- package/android/gradle.properties +6 -0
- package/android/settings.gradle +3 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +307 -0
- package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkPackage.kt +16 -0
- package/ios/TapjoyReactNativeSdk-Bridging-Header.h +6 -0
- package/ios/TapjoyReactNativeSdk.m +34 -0
- package/ios/TapjoyReactNativeSdk.swift +232 -0
- package/ios/TapjoyReactNativeSdk.xcodeproj/project.pbxproj +291 -0
- package/ios/TapjoyReactNativeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/TapjoyReactNativeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/TapjoyReactNativeSdk.xcodeproj/xcshareddata/xcschemes/TapjoyReactNativeSdk.xcscheme +67 -0
- package/lib/commonjs/TJPlacement.js +65 -0
- package/lib/commonjs/TJPlacement.js.map +1 -0
- package/lib/commonjs/TJPrivacyPolicy.js +25 -0
- package/lib/commonjs/TJPrivacyPolicy.js.map +1 -0
- package/lib/commonjs/TJVersion.js +22 -0
- package/lib/commonjs/TJVersion.js.map +1 -0
- package/lib/commonjs/index.js +42 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/TJPlacement.js +58 -0
- package/lib/module/TJPlacement.js.map +1 -0
- package/lib/module/TJPrivacyPolicy.js +18 -0
- package/lib/module/TJPrivacyPolicy.js.map +1 -0
- package/lib/module/TJVersion.js +14 -0
- package/lib/module/TJVersion.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/TJPlacement.d.ts +17 -0
- package/lib/typescript/TJPlacement.d.ts.map +1 -0
- package/lib/typescript/TJPrivacyPolicy.d.ts +8 -0
- package/lib/typescript/TJPrivacyPolicy.d.ts.map +1 -0
- package/lib/typescript/TJVersion.d.ts +5 -0
- package/lib/typescript/TJVersion.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/package/src/TJPlacement.d.ts +17 -0
- package/lib/typescript/package/src/TJPlacement.d.ts.map +1 -0
- package/lib/typescript/package/src/TJPrivacyPolicy.d.ts +8 -0
- package/lib/typescript/package/src/TJPrivacyPolicy.d.ts.map +1 -0
- package/lib/typescript/package/src/TJVersion.d.ts +5 -0
- package/lib/typescript/package/src/TJVersion.d.ts.map +1 -0
- package/lib/typescript/package/src/index.d.ts +7 -0
- package/lib/typescript/package/src/index.d.ts.map +1 -0
- package/lib/typescript/src/TJPlacement.d.ts +17 -0
- package/lib/typescript/src/TJPlacement.d.ts.map +1 -0
- package/lib/typescript/src/TJPrivacyPolicy.d.ts +8 -0
- package/lib/typescript/src/TJPrivacyPolicy.d.ts.map +1 -0
- package/lib/typescript/src/TJVersion.d.ts +5 -0
- package/lib/typescript/src/TJVersion.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +163 -0
- package/src/TJPlacement.ts +81 -0
- package/src/TJPrivacyPolicy.ts +23 -0
- package/src/TJVersion.ts +15 -0
- package/src/index.ts +24 -0
- package/tapjoy-react-native-sdk.podspec +36 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Tapjoy React Native SDK
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
## Module Development
|
|
5
|
+
### Setup Environment
|
|
6
|
+
- Please check first [this general react-native setup document](https://reactnative.dev/docs/environment-setup).
|
|
7
|
+
- Nodejs version 18.15.0
|
|
8
|
+
- Ruby version 2.7.6
|
|
9
|
+
- Highly recommend to use [`asdf`](https://asdf-vm.com/) for the runtime management.
|
|
10
|
+
```shell
|
|
11
|
+
asdf install #this command will install ruby, nodejs
|
|
12
|
+
```
|
|
13
|
+
- Yarn install
|
|
14
|
+
```shell
|
|
15
|
+
npm install --global yarn
|
|
16
|
+
```
|
|
17
|
+
- ios-deploy tool
|
|
18
|
+
```shell
|
|
19
|
+
brew install ios-deploy
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Install Dependency
|
|
23
|
+
|
|
24
|
+
`yarn` command will install all dependencies including pod dependency.
|
|
25
|
+
```shell
|
|
26
|
+
yarn
|
|
27
|
+
```
|
|
28
|
+
### Running Example
|
|
29
|
+
|
|
30
|
+
For iOS
|
|
31
|
+
```shell
|
|
32
|
+
yarn example ios
|
|
33
|
+
```
|
|
34
|
+
For Android
|
|
35
|
+
```shell
|
|
36
|
+
yarn example android
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Javascript
|
|
40
|
+
`./src/index.ts` is the typescript module entry point. No wrapper is introduced yet.
|
|
41
|
+
|
|
42
|
+
### iOS
|
|
43
|
+
You can find `./ios/TapjoyReactNativeSdk.swift` and `./ios/TapjoyReactNativeSdk.m` for the iOS bridge logic.
|
|
44
|
+
|
|
45
|
+
### Android
|
|
46
|
+
You can find `./android/src/main/java/com/tapjoy/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt` for the Android bridge logic.
|
|
47
|
+
|
|
48
|
+
## Debugging
|
|
49
|
+
|
|
50
|
+
### Javascript
|
|
51
|
+
Press 'D' while the app is running. And select `Debug with Chrome`. Debug in Chrome inspector.
|
|
52
|
+
|
|
53
|
+
### iOS
|
|
54
|
+
In Xcode, use `Debug > Attach to Process` feature
|
|
55
|
+
|
|
56
|
+
### Android
|
|
57
|
+
In Android Studio, use `Run > Attach Debugger to Android Process` feature.
|
|
58
|
+
|
|
59
|
+
## Resources
|
|
60
|
+
### Environment setup
|
|
61
|
+
https://reactnative.dev/docs/environment-setup
|
|
62
|
+
|
|
63
|
+
### React Native iOS module
|
|
64
|
+
https://reactnative.dev/docs/native-modules-ios
|
|
65
|
+
|
|
66
|
+
### React Native Android Doc
|
|
67
|
+
https://reactnative.dev/docs/native-modules-android
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["TapjoyReactNativeSdk_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.3.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
classpath "com.facebook.react:react-native-gradle-plugin"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def isNewArchitectureEnabled() {
|
|
19
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.android.library"
|
|
23
|
+
apply plugin: "kotlin-android"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
27
|
+
|
|
28
|
+
if (isNewArchitectureEnabled()) {
|
|
29
|
+
apply plugin: "com.facebook.react"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["TapjoyReactNativeSdk_" + name]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def getExtOrIntegerDefault(name) {
|
|
37
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TapjoyReactNativeSdk_" + name]).toInteger()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
android {
|
|
41
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
42
|
+
|
|
43
|
+
defaultConfig {
|
|
44
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
45
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
46
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
47
|
+
}
|
|
48
|
+
buildTypes {
|
|
49
|
+
release {
|
|
50
|
+
minifyEnabled false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
lintOptions {
|
|
55
|
+
disable "GradleCompatible"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
compileOptions {
|
|
59
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
60
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
repositories {
|
|
66
|
+
mavenCentral()
|
|
67
|
+
google()
|
|
68
|
+
maven {
|
|
69
|
+
name "Tapjoy's maven repo"
|
|
70
|
+
url "https://sdk.tapjoy.com/"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
75
|
+
|
|
76
|
+
dependencies {
|
|
77
|
+
// For < 0.71, this will be from the local maven repo
|
|
78
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
79
|
+
//noinspection GradleDynamicVersion
|
|
80
|
+
implementation 'com.facebook.react:react-native:0.71.4'
|
|
81
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
82
|
+
implementation 'com.tapjoy:tapjoy-android-sdk:13.0.1'
|
|
83
|
+
implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (isNewArchitectureEnabled()) {
|
|
87
|
+
react {
|
|
88
|
+
jsRootDir = file("../src/")
|
|
89
|
+
libraryName = "TapjoyReactNativeSdk"
|
|
90
|
+
codegenJavaPackageName = "com.tapjoyreactnativesdk"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
package com.tapjoyreactnativesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.tapjoy.TJConnectListener
|
|
5
|
+
import com.tapjoy.TJGetCurrencyBalanceListener
|
|
6
|
+
import com.tapjoy.TJSpendCurrencyListener
|
|
7
|
+
import com.tapjoy.TJAwardCurrencyListener
|
|
8
|
+
import com.tapjoy.TJSetUserIDListener
|
|
9
|
+
import com.tapjoy.Tapjoy
|
|
10
|
+
import com.tapjoy.TapjoyConnectCore
|
|
11
|
+
import com.tapjoy.TJError;
|
|
12
|
+
import com.tapjoy.TJPlacement;
|
|
13
|
+
import com.tapjoy.TJActionRequest;
|
|
14
|
+
import com.tapjoy.TJPlacementListener;
|
|
15
|
+
import java.util.Hashtable
|
|
16
|
+
import kotlin.collections.HashMap
|
|
17
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
|
+
|
|
19
|
+
class TapjoyReactNativeSdkModule(reactContext: ReactApplicationContext) :
|
|
20
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
21
|
+
|
|
22
|
+
val messageConnectionFailed = "connection failed"
|
|
23
|
+
var placements = HashMap<String, TJPlacement>()
|
|
24
|
+
|
|
25
|
+
companion object {
|
|
26
|
+
const val NAME = "TapjoyReactNativeSdk"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun getName(): String {
|
|
30
|
+
return NAME
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun getConstants(): Map<String, kotlin.Any> {
|
|
34
|
+
return HashMap();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private var listenerCount = 0
|
|
38
|
+
|
|
39
|
+
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
40
|
+
if (listenerCount > 0) {
|
|
41
|
+
reactApplicationContext
|
|
42
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
43
|
+
.emit(eventName, params)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
fun addListener(eventName: String) {
|
|
49
|
+
listenerCount += 1
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
fun removeListeners(count: Int) {
|
|
54
|
+
listenerCount -= count
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Connect to Tapjoy.This class has no useful logic; it's just a documentation example.
|
|
59
|
+
*
|
|
60
|
+
* @Param sdkKey: SDK key the app.
|
|
61
|
+
* @Param connectFlags: Dictionary for the connection flag values.@param T the type of a member in this group.
|
|
62
|
+
* @return true to javascript if it is succeeded otherwise throws error
|
|
63
|
+
*/
|
|
64
|
+
@ReactMethod
|
|
65
|
+
fun connect(sdkKey: String, connectFlags: ReadableMap, promise: Promise) {
|
|
66
|
+
TapjoyConnectCore.setPlugin("ReactNative");
|
|
67
|
+
|
|
68
|
+
Tapjoy.connect(this.currentActivity?.applicationContext, sdkKey, connectFlags.toHashtable(), object : TJConnectListener {
|
|
69
|
+
override fun onConnectSuccess() {
|
|
70
|
+
Tapjoy.setActivity(currentActivity)
|
|
71
|
+
promise.resolve(true)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override fun onConnectFailure() {
|
|
75
|
+
promise.reject(messageConnectionFailed, Exception(messageConnectionFailed))
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@ReactMethod
|
|
81
|
+
fun getCurrencyBalance(promise: Promise) {
|
|
82
|
+
Tapjoy.getCurrencyBalance(object : TJGetCurrencyBalanceListener {
|
|
83
|
+
|
|
84
|
+
override fun onGetCurrencyBalanceResponse(currencyName: String, balance: Int) {
|
|
85
|
+
val currencyObj = Arguments.createMap().apply {
|
|
86
|
+
putString("currencyName", currencyName)
|
|
87
|
+
putInt("amount", balance)
|
|
88
|
+
}
|
|
89
|
+
promise.resolve(currencyObj)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
override fun onGetCurrencyBalanceResponseFailure(error: String) {
|
|
93
|
+
promise.reject(error)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
fun spendCurrency(amount: Int, promise: Promise) {
|
|
100
|
+
Tapjoy.spendCurrency(amount, object : TJSpendCurrencyListener {
|
|
101
|
+
|
|
102
|
+
override fun onSpendCurrencyResponse(currencyName: String, balance: Int) {
|
|
103
|
+
val currencyObj = Arguments.createMap().apply {
|
|
104
|
+
putString("currencyName", currencyName)
|
|
105
|
+
putInt("amount", balance)
|
|
106
|
+
}
|
|
107
|
+
promise.resolve(currencyObj)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override fun onSpendCurrencyResponseFailure(error: String) {
|
|
111
|
+
promise.reject(error)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
fun awardCurrency(amount: Int, promise: Promise) {
|
|
118
|
+
Tapjoy.awardCurrency(amount, object : TJAwardCurrencyListener {
|
|
119
|
+
|
|
120
|
+
override fun onAwardCurrencyResponse(currencyName: String, balance: Int) {
|
|
121
|
+
val currencyObj = Arguments.createMap().apply {
|
|
122
|
+
putString("currencyName", currencyName)
|
|
123
|
+
putInt("amount", balance)
|
|
124
|
+
}
|
|
125
|
+
promise.resolve(currencyObj)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
override fun onAwardCurrencyResponseFailure(error: String) {
|
|
129
|
+
promise.reject(error)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@ReactMethod
|
|
135
|
+
fun setUserId(userId: String, promise: Promise) {
|
|
136
|
+
Tapjoy.setUserID(userId, object: TJSetUserIDListener {
|
|
137
|
+
override fun onSetUserIDSuccess() {
|
|
138
|
+
promise.resolve(userId)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
override fun onSetUserIDFailure(error: String?) {
|
|
142
|
+
promise.reject("Set User ID Error", Exception(error))
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactMethod
|
|
148
|
+
fun setDebugEnabled(enabled: Boolean) {
|
|
149
|
+
Tapjoy.setDebugEnabled(enabled)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
153
|
+
fun isConnected(): Boolean {
|
|
154
|
+
return Tapjoy.isConnected()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Request content for a given placement.
|
|
159
|
+
*
|
|
160
|
+
* @param placementName Case-sensitive placement name string. Must not be empty or null.
|
|
161
|
+
*/
|
|
162
|
+
@ReactMethod
|
|
163
|
+
fun requestPlacement(placementName: String) {
|
|
164
|
+
val listener = object : TJPlacementListener {
|
|
165
|
+
override fun onRequestSuccess(placement: TJPlacement) {
|
|
166
|
+
val parameters = Arguments.createMap().apply {
|
|
167
|
+
putString("name", "requestDidSucceed")
|
|
168
|
+
putString("placement", placement.name)
|
|
169
|
+
}
|
|
170
|
+
sendEvent("TapjoyPlacement", parameters)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
override fun onRequestFailure(placement: TJPlacement, error: TJError) {
|
|
174
|
+
val parameters = Arguments.createMap().apply {
|
|
175
|
+
putString("name", "requestDidFail")
|
|
176
|
+
putString("placement", placement.name)
|
|
177
|
+
putString("error", error.message)
|
|
178
|
+
}
|
|
179
|
+
sendEvent("TapjoyPlacement", parameters)
|
|
180
|
+
placements.remove(placement.name)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
override fun onContentReady(placement: TJPlacement) {
|
|
184
|
+
val parameters = Arguments.createMap().apply {
|
|
185
|
+
putString("name", "contentIsReady")
|
|
186
|
+
putString("placement", placement.name)
|
|
187
|
+
}
|
|
188
|
+
sendEvent("TapjoyPlacement", parameters)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
override fun onContentShow(placement: TJPlacement) {
|
|
192
|
+
val parameters = Arguments.createMap().apply {
|
|
193
|
+
putString("name", "contentDidAppear")
|
|
194
|
+
putString("placement", placement.name)
|
|
195
|
+
}
|
|
196
|
+
sendEvent("TapjoyPlacement", parameters)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
override fun onContentDismiss(placement: TJPlacement) {
|
|
200
|
+
val parameters = Arguments.createMap().apply {
|
|
201
|
+
putString("name", "contentDidDisappear")
|
|
202
|
+
putString("placement", placement.name)
|
|
203
|
+
}
|
|
204
|
+
sendEvent("TapjoyPlacement", parameters)
|
|
205
|
+
placements.remove(placement.name)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
override fun onPurchaseRequest(placement: TJPlacement, actionRequest: TJActionRequest, name: String) {
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
override fun onRewardRequest(placement: TJPlacement, actionRequest: TJActionRequest, currencyName: String, value: Int) {
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
override fun onClick(placement: TJPlacement) {
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
val placement = Tapjoy.getPlacement(placementName, listener)
|
|
221
|
+
placements[placement.name] = placement
|
|
222
|
+
placement.requestContent()
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Show content for a given placement.
|
|
227
|
+
*
|
|
228
|
+
* @param placementName Case-sensitive placement name string. Must not be empty or null.
|
|
229
|
+
*/
|
|
230
|
+
@ReactMethod
|
|
231
|
+
fun showPlacement(placementName: String) {
|
|
232
|
+
placements[placementName]?.showContent()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Check if content has been downloaded and ready to show for a given placement.
|
|
237
|
+
*
|
|
238
|
+
* @param placementName Case-sensitive placement name string. Must not be empty or null.
|
|
239
|
+
*
|
|
240
|
+
* @return true if content has been cached and ready to show.
|
|
241
|
+
*/
|
|
242
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
243
|
+
fun isContentReady(placementName: String): Boolean {
|
|
244
|
+
return placements[placementName]?.isContentReady ?: false
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Check if content is available to cache or stream for a given placement.
|
|
249
|
+
*
|
|
250
|
+
* @param placementName Case-sensitive placement name string. Must not be empty or null.
|
|
251
|
+
*
|
|
252
|
+
* @return true if content is available to cache or stream.
|
|
253
|
+
*/
|
|
254
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
255
|
+
fun isContentAvailable(placementName: String): Boolean {
|
|
256
|
+
return placements[placementName]?.isContentAvailable ?: false
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Indicate if the user falls in any of the GDPR applicable countries
|
|
261
|
+
*
|
|
262
|
+
* @param gdprApplicable true if GDPR applies to this user, false otherwise
|
|
263
|
+
*/
|
|
264
|
+
@ReactMethod
|
|
265
|
+
fun setSubjectToGDPR(gdprApplicable: Boolean){
|
|
266
|
+
Tapjoy.getPrivacyPolicy().setSubjectToGDPR(gdprApplicable)
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* This method will set ad_tracking_enabled to false for Tapjoy which only shows the user contextual ads. No ad tracking will be done on this user.
|
|
270
|
+
*
|
|
271
|
+
* @param isBelowConsentAge true if below consent age (COPPA) applies to this user, false otherwise
|
|
272
|
+
*/
|
|
273
|
+
@ReactMethod
|
|
274
|
+
fun setBelowConsentAge(isBelowConsentAge: Boolean){
|
|
275
|
+
Tapjoy.getPrivacyPolicy().setBelowConsentAge(isBelowConsentAge)
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* This is used for sending US Privacy value to behavioral advertising such as in the context of GDPR
|
|
279
|
+
*
|
|
280
|
+
* @param privacyValue The privacy value string eg. "1YNN" where 1 is char in string for the version, Y = YES, N = No, - = Not Applicable
|
|
281
|
+
*/
|
|
282
|
+
@ReactMethod
|
|
283
|
+
fun setUSPrivacy(isUsPrivacy: String){
|
|
284
|
+
Tapjoy.getPrivacyPolicy().setUSPrivacy(isUsPrivacy)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* This is used for sending User's consent to behavioral advertising such as in the context of GDPR
|
|
289
|
+
*
|
|
290
|
+
* @param userConsent The value can be "0" (User has not provided consent), "1" (User has provided consent) or a daisybit string as suggested in IAB's Transparency and Consent Framework
|
|
291
|
+
*/
|
|
292
|
+
@ReactMethod
|
|
293
|
+
fun setUserConsent(userConsent: String){
|
|
294
|
+
Tapjoy.getPrivacyPolicy().setUserConsent(userConsent)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private fun ReadableMap.toHashtable(): Hashtable<String, Any> {
|
|
298
|
+
val hashtable = Hashtable<String, Any>()
|
|
299
|
+
val iterator = this.keySetIterator()
|
|
300
|
+
while (iterator.hasNextKey()) {
|
|
301
|
+
val key = iterator.nextKey()
|
|
302
|
+
val value = this.getString(key)
|
|
303
|
+
hashtable[key] = value?: continue
|
|
304
|
+
}
|
|
305
|
+
return hashtable
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.tapjoyreactnativesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class TapjoyReactNativeSdkPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(TapjoyReactNativeSdkModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(TapjoyReactNativeSdk, NSObject)
|
|
5
|
+
|
|
6
|
+
#pragma mark - SDK
|
|
7
|
+
RCT_EXTERN_METHOD(connect:(NSString *)sdkKey connectFlags:(NSDictionary *)connectFlags resolve:(RCTPromiseResolveBlock *)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
8
|
+
RCT_EXTERN_METHOD(setDebugEnabled:(BOOL)enabled)
|
|
9
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(isConnected)
|
|
10
|
+
RCT_EXTERN_METHOD(setUserId:(NSString *)userId resolve:(RCTPromiseResolveBlock *)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
11
|
+
|
|
12
|
+
#pragma mark - Placements
|
|
13
|
+
RCT_EXTERN_METHOD(requestPlacement:(NSString *)name)
|
|
14
|
+
RCT_EXTERN_METHOD(showPlacement:(NSString *)name)
|
|
15
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(isContentReady:(NSString *)name)
|
|
16
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(isContentAvailable:(NSString *)name)
|
|
17
|
+
|
|
18
|
+
#pragma mark - Currency
|
|
19
|
+
RCT_EXTERN_METHOD(getCurrencyBalance:(RCTPromiseResolveBlock *)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
20
|
+
RCT_EXTERN_METHOD(spendCurrency:(int)amount resolve:(RCTPromiseResolveBlock *)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
21
|
+
RCT_EXTERN_METHOD(awardCurrency:(int)amount resolve:(RCTPromiseResolveBlock *)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
22
|
+
|
|
23
|
+
#pragma mark - Privacy
|
|
24
|
+
RCT_EXTERN_METHOD(setSubjectToGDPR:(BOOL)isSubjectToGDPR)
|
|
25
|
+
RCT_EXTERN_METHOD(setBelowConsentAge:(BOOL)isBelowConsentAge)
|
|
26
|
+
RCT_EXTERN_METHOD(setUSPrivacy:(NSString *)privacyValue)
|
|
27
|
+
RCT_EXTERN_METHOD(setUserConsent:(NSString *)userConsent)
|
|
28
|
+
|
|
29
|
+
+ (BOOL)requiresMainQueueSetup
|
|
30
|
+
{
|
|
31
|
+
return NO;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@end
|