tapjoy-react-native-sdk 14.2.0 → 14.3.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/android/build.gradle +2 -2
- package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +1 -1
- package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +22 -1
- package/example/Gemfile +2 -1
- package/example/android/app/build.gradle +1 -1
- package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.kt +2 -1
- package/example/android/build.gradle +4 -4
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/android/gradle.properties +1 -1
- package/example/android/gradlew +4 -1
- package/example/android/gradlew.bat +2 -0
- package/example/package-lock.json +8605 -0
- package/example/package.json +9 -5
- package/example/src/MainScreen.tsx +33 -27
- package/example/src/OfferwallScreen.tsx +67 -4
- package/example/src/Styles.ts +13 -5
- package/example/src/UserProperties.tsx +13 -1
- package/ios/TapjoyReactNativeSdk.swift +1 -3
- package/lib/commonjs/TJConnect.js +5 -0
- package/lib/commonjs/TJEntryPoint.js +14 -0
- package/lib/commonjs/TJOfferwallDiscoverView.js +25 -0
- package/lib/commonjs/TJPlacement.js +156 -0
- package/lib/commonjs/TJPrivacyPolicy.js +74 -0
- package/lib/commonjs/TJPurchase.js +8 -0
- package/lib/commonjs/TJSegment.js +8 -0
- package/lib/commonjs/TJStatus.js +7 -0
- package/lib/commonjs/TJUtil.js +14 -0
- package/lib/commonjs/TJVersion.js +14 -0
- package/lib/commonjs/Tapjoy.js +212 -0
- package/lib/commonjs/TapjoyEvent.js +1 -0
- package/lib/commonjs/index.js +10 -0
- package/lib/typescript/TJConnect.d.ts +4 -0
- package/lib/typescript/TJEntryPoint.d.ts +13 -0
- package/lib/typescript/TJOfferwallDiscoverView.d.ts +17 -0
- package/lib/typescript/TJPlacement.d.ts +96 -0
- package/lib/typescript/TJPrivacyPolicy.d.ts +14 -0
- package/lib/typescript/TJPurchase.d.ts +4 -0
- package/lib/typescript/TJSegment.d.ts +7 -0
- package/lib/typescript/TJStatus.d.ts +6 -0
- package/lib/typescript/TJUtil.d.ts +4 -0
- package/lib/typescript/TJVersion.d.ts +4 -0
- package/lib/typescript/Tapjoy.d.ts +148 -0
- package/lib/typescript/TapjoyEvent.d.ts +5 -0
- package/lib/typescript/index.d.ts +10 -0
- package/package.json +5 -4
- package/src/TJOfferwallDiscoverView.tsx +3 -2
- package/src/TJPlacement.ts +25 -3
- package/src/TJPrivacyPolicy.ts +9 -0
- package/src/TJVersion.ts +1 -1
- package/src/Tapjoy.ts +240 -0
- package/src/TapjoyEvent.ts +5 -0
- package/src/index.ts +1 -19
- package/tapjoy-react-native-sdk.podspec +1 -1
package/example/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "TapjoyReactNativeSdkExample",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"android": "react-native run-android",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"pods": "pod-install --quiet"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"tapjoy-react-native-sdk": "file:../",
|
|
12
13
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
13
14
|
"@react-native-community/masked-view": "^0.1.11",
|
|
14
15
|
"@react-native-picker/picker": "^2.8.1",
|
|
@@ -16,21 +17,24 @@
|
|
|
16
17
|
"@react-navigation/native": "^6.1.18",
|
|
17
18
|
"dayjs": "^1.11.13",
|
|
18
19
|
"react": "18.3.1",
|
|
19
|
-
"react-native": "0.
|
|
20
|
+
"react-native": "0.76.6",
|
|
20
21
|
"react-native-gesture-handler": "^2.20.0",
|
|
21
22
|
"react-native-picker-select": "^9.3.1",
|
|
22
23
|
"react-native-reanimated": "^3.15.3",
|
|
23
24
|
"react-native-safe-area-context": "^4.11.0",
|
|
24
25
|
"react-native-screens": "^3.34.0",
|
|
25
|
-
"react-native-
|
|
26
|
-
"react-native-
|
|
26
|
+
"react-native-toast-message": "^2.2.1",
|
|
27
|
+
"react-native-tracking-transparency": "^0.1.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@babel/core": "^7.25.2",
|
|
30
31
|
"@babel/preset-env": "^7.25.4",
|
|
31
32
|
"@babel/runtime": "^7.25.6",
|
|
33
|
+
"@react-native-community/cli": "15.0.1",
|
|
34
|
+
"@react-native-community/cli-platform-android": "15.0.1",
|
|
35
|
+
"@react-native-community/cli-platform-ios": "15.0.1",
|
|
36
|
+
"@react-native/metro-config": "^0.76.6",
|
|
32
37
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
33
|
-
"@react-native/metro-config": "^0.75.3",
|
|
34
38
|
"metro-react-native-babel-preset": "0.77.0"
|
|
35
39
|
},
|
|
36
40
|
"engines": {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
Platform,
|
|
7
7
|
Text,
|
|
8
8
|
ScrollView,
|
|
9
|
-
NativeEventEmitter,
|
|
10
|
-
NativeModules,
|
|
11
9
|
} from 'react-native';
|
|
12
10
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
13
11
|
import {
|
|
@@ -16,21 +14,16 @@ import {
|
|
|
16
14
|
} from 'react-native-tracking-transparency';
|
|
17
15
|
import styles from './Styles';
|
|
18
16
|
import Button from './Button';
|
|
19
|
-
import Tapjoy, { TJVersion,
|
|
17
|
+
import Tapjoy, { TJVersion, TapjoyEvent } from 'tapjoy-react-native-sdk';
|
|
20
18
|
import { ConnectContext } from './ConnectContext';
|
|
21
19
|
|
|
22
20
|
const MainScreen: React.FC = () => {
|
|
23
21
|
const [sdkKey, setSdkKey] = useState<string>('');
|
|
24
22
|
const [isConnecting, setIsConnecting] = useState<boolean>(false);
|
|
23
|
+
const [curerncySpendAwardAmount, setCurrencySpendAwardAmount] = useState<string>('10');
|
|
25
24
|
const [statusLabelText, setStatusLabelText] = useState('Status Message');
|
|
26
25
|
const { isSdkConnected, setIsSdkConnected } = useContext(ConnectContext);
|
|
27
26
|
|
|
28
|
-
interface TapjoyEvent {
|
|
29
|
-
name: string;
|
|
30
|
-
code: string;
|
|
31
|
-
message: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
27
|
useEffect(() => {
|
|
35
28
|
retrieveSdkKey().then();
|
|
36
29
|
}, []);
|
|
@@ -65,21 +58,11 @@ const MainScreen: React.FC = () => {
|
|
|
65
58
|
if (trackingStatus !== 'authorized' && trackingStatus !== 'unavailable') {
|
|
66
59
|
await requestTrackingPermission();
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
TapjoyEventType,
|
|
73
|
-
(event: TapjoyEvent) => {
|
|
74
|
-
if (event.name === TJConnect.TJC_CONNECT_WARNING) {
|
|
75
|
-
subscription.remove();
|
|
76
|
-
setStatusLabelText(
|
|
77
|
-
`Tapjoy SDK connected with Warning: ErrorCode: ${event.code} ${event.message} `
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
61
|
+
|
|
62
|
+
await Tapjoy.connect(sdkKey, flags, (event: TapjoyEvent) => {
|
|
63
|
+
setStatusLabelText(`Tapjoy SDK connected with Warning: ErrorCode: ${event.code} ${event.message} `);
|
|
64
|
+
},
|
|
81
65
|
);
|
|
82
|
-
await Tapjoy.connect(sdkKey, flags);
|
|
83
66
|
setIsConnecting(false);
|
|
84
67
|
setStatusLabelText(
|
|
85
68
|
'Tapjoy SDK Connected' +
|
|
@@ -96,6 +79,14 @@ const MainScreen: React.FC = () => {
|
|
|
96
79
|
}
|
|
97
80
|
};
|
|
98
81
|
|
|
82
|
+
const parseAmount = (amount: string): number => {
|
|
83
|
+
const parsedAmount = parseInt(amount);
|
|
84
|
+
if (isNaN(parsedAmount)) {
|
|
85
|
+
throw new Error('Invalid amount');
|
|
86
|
+
}
|
|
87
|
+
return parsedAmount;
|
|
88
|
+
};
|
|
89
|
+
|
|
99
90
|
const getCurrencyBalance = async () => {
|
|
100
91
|
try {
|
|
101
92
|
let result = await Tapjoy.getCurrencyBalance();
|
|
@@ -112,28 +103,33 @@ const MainScreen: React.FC = () => {
|
|
|
112
103
|
|
|
113
104
|
const spendCurrency = async () => {
|
|
114
105
|
try {
|
|
115
|
-
|
|
106
|
+
const amount = parseAmount(curerncySpendAwardAmount);
|
|
116
107
|
let result = await Tapjoy.spendCurrency(amount);
|
|
117
108
|
setStatusLabelText(
|
|
118
109
|
'spendCurrency returned ' + result.currencyName + ': ' + result.amount
|
|
119
110
|
);
|
|
120
111
|
} catch (error: any) {
|
|
121
|
-
setStatusLabelText(error.toString());
|
|
112
|
+
setStatusLabelText('spendCurrency error: ' + error.toString());
|
|
122
113
|
}
|
|
123
114
|
};
|
|
124
115
|
|
|
125
116
|
const awardCurrency = async () => {
|
|
126
117
|
try {
|
|
127
|
-
|
|
118
|
+
const amount = parseAmount(curerncySpendAwardAmount);
|
|
128
119
|
let result = await Tapjoy.awardCurrency(amount);
|
|
129
120
|
setStatusLabelText(
|
|
130
121
|
'awardCurrency returned ' + result.currencyName + ': ' + result.amount
|
|
131
122
|
);
|
|
132
123
|
} catch (error: any) {
|
|
133
|
-
setStatusLabelText(error.toString());
|
|
124
|
+
setStatusLabelText('awardCurrency error: ' + error.toString());
|
|
134
125
|
}
|
|
135
126
|
};
|
|
136
127
|
|
|
128
|
+
const handleAmountChange = (text: string) => {
|
|
129
|
+
const numericText = text.replace(/[^0-9]/g, '');
|
|
130
|
+
setCurrencySpendAwardAmount(numericText);
|
|
131
|
+
};
|
|
132
|
+
|
|
137
133
|
return (
|
|
138
134
|
<View style={styles.mainContainer}>
|
|
139
135
|
<ScrollView>
|
|
@@ -157,6 +153,16 @@ const MainScreen: React.FC = () => {
|
|
|
157
153
|
</View>
|
|
158
154
|
<View style={styles.currencyOuterContainer}>
|
|
159
155
|
<Text style={styles.labelText}>{'Managed Currency:'}</Text>
|
|
156
|
+
<View style={styles.inputContainer}>
|
|
157
|
+
<Text style={styles.userPropertiesLabel}>Amount:</Text>
|
|
158
|
+
<TextInput
|
|
159
|
+
style={styles.textInput}
|
|
160
|
+
keyboardType='numeric'
|
|
161
|
+
value={curerncySpendAwardAmount}
|
|
162
|
+
onChangeText={handleAmountChange}
|
|
163
|
+
placeholder="Managed Currency value"
|
|
164
|
+
/>
|
|
165
|
+
</View>
|
|
160
166
|
<View style={styles.currencyInnerContainer}>
|
|
161
167
|
<Button
|
|
162
168
|
style={styles.buttonGap}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useEffect, useState, useContext } from 'react';
|
|
2
|
-
import { useFocusEffect } from '@react-navigation/native';
|
|
3
2
|
import {
|
|
4
3
|
FlatList,
|
|
5
4
|
SafeAreaView,
|
|
@@ -12,7 +11,7 @@ import dayjs from 'dayjs';
|
|
|
12
11
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
13
12
|
import Button from './Button';
|
|
14
13
|
import styles, { pickerSelectStyles } from './Styles';
|
|
15
|
-
import
|
|
14
|
+
import {TJPlacement, TJPurchase } from 'tapjoy-react-native-sdk';
|
|
16
15
|
import RNPickerSelect from 'react-native-picker-select';
|
|
17
16
|
import TJEntryPoint from '../../src/TJEntryPoint';
|
|
18
17
|
import { ConnectContext } from './ConnectContext';
|
|
@@ -30,6 +29,8 @@ const OfferwallScreen: React.FC = () => {
|
|
|
30
29
|
const [currencyId, _setCurrencyId] = useState<string>('');
|
|
31
30
|
const [currencyBalance, _setCurrencyBalance] = useState<string>('');
|
|
32
31
|
const [requiredAmount, _setRequiredAmount] = useState<string>('');
|
|
32
|
+
const [purchaseAmount, _setPurchaseAmount] = useState<string>('0.99');
|
|
33
|
+
const [purchaseCode, _setPurchaseCode] = useState<string>('USD');
|
|
33
34
|
const { isSdkConnected, setIsSdkConnected } = useContext(ConnectContext);
|
|
34
35
|
|
|
35
36
|
useEffect(() => {
|
|
@@ -48,6 +49,14 @@ const OfferwallScreen: React.FC = () => {
|
|
|
48
49
|
retrieveRequiredAmount().then();
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
retrievePurchaseCurrency().then();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
retrievePurchaseCode().then();
|
|
58
|
+
});
|
|
59
|
+
|
|
51
60
|
const retrieveStoredPlacementName = () => {
|
|
52
61
|
AsyncStorage.getItem('placementName').then(async (value) => {
|
|
53
62
|
if (value !== null) {
|
|
@@ -89,6 +98,28 @@ const OfferwallScreen: React.FC = () => {
|
|
|
89
98
|
}
|
|
90
99
|
};
|
|
91
100
|
|
|
101
|
+
const retrievePurchaseCurrency = async () => {
|
|
102
|
+
try {
|
|
103
|
+
const value = await AsyncStorage.getItem('purchaseAmount');
|
|
104
|
+
if (value !== null) {
|
|
105
|
+
await setPurchaseAmount(value);
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
addLogItem(`Failed to retrieve purchase amount: ${error}`);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const retrievePurchaseCode = async () => {
|
|
113
|
+
try {
|
|
114
|
+
const value = await AsyncStorage.getItem('purchaseCode');
|
|
115
|
+
if (value !== null) {
|
|
116
|
+
await setPurchaseCode(value);
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
addLogItem(`Failed to retrieve purchase amount: ${error}`);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
92
123
|
const setCurrencyId = async (id: string) => {
|
|
93
124
|
_setCurrencyId(id);
|
|
94
125
|
let trimmedCurrencyId = id.trim();
|
|
@@ -107,6 +138,18 @@ const OfferwallScreen: React.FC = () => {
|
|
|
107
138
|
await AsyncStorage.setItem('requiredAmount', trimmedValue);
|
|
108
139
|
};
|
|
109
140
|
|
|
141
|
+
const setPurchaseAmount = async (newValue: string) => {
|
|
142
|
+
_setPurchaseAmount(newValue);
|
|
143
|
+
let trimmedValue = newValue.trim();
|
|
144
|
+
await AsyncStorage.setItem('purchaseAmount', trimmedValue);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const setPurchaseCode = async (newValue: string) => {
|
|
148
|
+
_setPurchaseCode(newValue);
|
|
149
|
+
let trimmedValue = newValue.trim();
|
|
150
|
+
await AsyncStorage.setItem('purchaseCode', trimmedValue);
|
|
151
|
+
};
|
|
152
|
+
|
|
110
153
|
const handleClearCurrencyId = async () => {
|
|
111
154
|
await setCurrencyId('');
|
|
112
155
|
};
|
|
@@ -201,8 +244,8 @@ const OfferwallScreen: React.FC = () => {
|
|
|
201
244
|
|
|
202
245
|
const sendPurchaseAction = () => {
|
|
203
246
|
const offerwallPurchase = new TJPurchase();
|
|
204
|
-
let currency =
|
|
205
|
-
let price =
|
|
247
|
+
let currency = purchaseCode;
|
|
248
|
+
let price = Number(purchaseAmount);
|
|
206
249
|
offerwallPurchase.trackPurchase(currency, price);
|
|
207
250
|
addLogItem(`Track Purchase Event - Currency: ${currency} Price: ${price}`);
|
|
208
251
|
};
|
|
@@ -357,6 +400,26 @@ const OfferwallScreen: React.FC = () => {
|
|
|
357
400
|
title={'\u2573'}
|
|
358
401
|
/>
|
|
359
402
|
</View>
|
|
403
|
+
<View style={styles.inputContainer}>
|
|
404
|
+
<Text style={styles.purchaseCurrencyLabel}>Purchase Amount:</Text>
|
|
405
|
+
<TextInput
|
|
406
|
+
style={styles.textInput}
|
|
407
|
+
value={purchaseAmount}
|
|
408
|
+
keyboardType={'numeric'}
|
|
409
|
+
onChangeText={setPurchaseAmount}
|
|
410
|
+
placeholder="E.g. 0.99"
|
|
411
|
+
placeholderTextColor="#888"
|
|
412
|
+
/>
|
|
413
|
+
<Text style={styles.purchaseCurrencyLabel}>Purchase Code:</Text>
|
|
414
|
+
<TextInput
|
|
415
|
+
style={styles.textInput}
|
|
416
|
+
value={purchaseCode}
|
|
417
|
+
keyboardType={'default'}
|
|
418
|
+
onChangeText={setPurchaseCode}
|
|
419
|
+
placeholder="E.g. USD."
|
|
420
|
+
placeholderTextColor="#888"
|
|
421
|
+
/>
|
|
422
|
+
</View>
|
|
360
423
|
<View style={styles.buttonContainer}>
|
|
361
424
|
<Button
|
|
362
425
|
onPress={sendPurchaseAction}
|
package/example/src/Styles.ts
CHANGED
|
@@ -67,13 +67,15 @@ const styles = StyleSheet.create({
|
|
|
67
67
|
},
|
|
68
68
|
textInput: {
|
|
69
69
|
flex: 1,
|
|
70
|
-
height:
|
|
70
|
+
height: 36,
|
|
71
71
|
borderWidth: 1,
|
|
72
72
|
borderColor: 'gray',
|
|
73
73
|
borderRadius: 10,
|
|
74
74
|
paddingLeft: 10,
|
|
75
75
|
paddingRight: 10,
|
|
76
76
|
color: 'black',
|
|
77
|
+
fontWeight: 'regular',
|
|
78
|
+
fontSize: 12,
|
|
77
79
|
},
|
|
78
80
|
textInputLabel: {
|
|
79
81
|
width: 50,
|
|
@@ -91,6 +93,7 @@ const styles = StyleSheet.create({
|
|
|
91
93
|
alignItems: 'flex-start',
|
|
92
94
|
justifyContent: 'center',
|
|
93
95
|
textAlign: 'left',
|
|
96
|
+
marginBottom: 6
|
|
94
97
|
},
|
|
95
98
|
currencyOuterContainer: {
|
|
96
99
|
flex: 1,
|
|
@@ -100,7 +103,6 @@ const styles = StyleSheet.create({
|
|
|
100
103
|
currencyInnerContainer: {
|
|
101
104
|
flex: 1,
|
|
102
105
|
flexDirection: 'row',
|
|
103
|
-
marginTop: 10,
|
|
104
106
|
},
|
|
105
107
|
currencyButtonContainer: {
|
|
106
108
|
flex: 1,
|
|
@@ -143,7 +145,13 @@ const styles = StyleSheet.create({
|
|
|
143
145
|
flexGrow: 1,
|
|
144
146
|
},
|
|
145
147
|
userPropertiesLabel: {
|
|
146
|
-
width:
|
|
148
|
+
width: 80,
|
|
149
|
+
paddingRight: 8,
|
|
150
|
+
color: 'black',
|
|
151
|
+
fontSize: 12,
|
|
152
|
+
},
|
|
153
|
+
purchaseCurrencyLabel: {
|
|
154
|
+
width: 100,
|
|
147
155
|
paddingRight: 14,
|
|
148
156
|
paddingLeft: 10,
|
|
149
157
|
color: 'black',
|
|
@@ -203,7 +211,7 @@ export const pickerSelectStyles = StyleSheet.create({
|
|
|
203
211
|
height: 40,
|
|
204
212
|
},
|
|
205
213
|
inputIOS: {
|
|
206
|
-
fontSize:
|
|
214
|
+
fontSize: 12,
|
|
207
215
|
paddingVertical: 12,
|
|
208
216
|
paddingHorizontal: 10,
|
|
209
217
|
borderColor: 'gray',
|
|
@@ -214,7 +222,7 @@ export const pickerSelectStyles = StyleSheet.create({
|
|
|
214
222
|
},
|
|
215
223
|
inputAndroid: {
|
|
216
224
|
height: 40,
|
|
217
|
-
fontSize:
|
|
225
|
+
fontSize: 12,
|
|
218
226
|
paddingHorizontal: 10,
|
|
219
227
|
paddingVertical: 8,
|
|
220
228
|
borderWidth: 1,
|
|
@@ -64,6 +64,7 @@ const UserProperties: React.FC = () => {
|
|
|
64
64
|
retrieveUserId().then();
|
|
65
65
|
retrieveUserLevel().then();
|
|
66
66
|
retrieveMaxLevel().then();
|
|
67
|
+
retrieveOptOut().then();
|
|
67
68
|
}
|
|
68
69
|
}, [isFocused]);
|
|
69
70
|
|
|
@@ -117,6 +118,16 @@ const UserProperties: React.FC = () => {
|
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
|
|
121
|
+
const retrieveOptOut = async () => {
|
|
122
|
+
try {
|
|
123
|
+
let privacyPolicy = new TJPrivacyPolicy();
|
|
124
|
+
const optOutStatus = await privacyPolicy.getOptOutAdvertisingID();
|
|
125
|
+
setOptOut(optOutStatus);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
setStatusLabelText(`Error fetching opt-out status:, ${error}`);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
120
131
|
const findStatus = (value: TJStatus) => {
|
|
121
132
|
return (
|
|
122
133
|
statusData.find((item) => item.value === value) || {
|
|
@@ -141,9 +152,10 @@ const UserProperties: React.FC = () => {
|
|
|
141
152
|
value: false,
|
|
142
153
|
label: 'False',
|
|
143
154
|
}
|
|
144
|
-
)
|
|
155
|
+
)
|
|
145
156
|
};
|
|
146
157
|
|
|
158
|
+
|
|
147
159
|
const initialUserConsentItem = findStatus(userConsent);
|
|
148
160
|
const initialBelowConsentAgeItem = findStatus(isBelowConsentAge);
|
|
149
161
|
const initialSubjectToGDPRItem = findStatus(isSubjectToGDPR);
|
|
@@ -233,12 +233,10 @@ class TapjoyReactNativeSdk: RCTEventEmitter {
|
|
|
233
233
|
Create content for a given placement.
|
|
234
234
|
- Parameter name: Case-sensitive placement name string. Must not be empty or null.
|
|
235
235
|
*/
|
|
236
|
-
@objc func createPlacement(_ name: String)
|
|
236
|
+
@objc func createPlacement(_ name: String) {
|
|
237
237
|
if let placement = TJPlacement(name: name, delegate: self) {
|
|
238
238
|
placements[name] = placement
|
|
239
|
-
return placement
|
|
240
239
|
}
|
|
241
|
-
return nil
|
|
242
240
|
}
|
|
243
241
|
|
|
244
242
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var TJEntryPoint;
|
|
2
|
+
(function (TJEntryPoint) {
|
|
3
|
+
TJEntryPoint["TJEntryPointUnknown"] = "";
|
|
4
|
+
TJEntryPoint["TJEntryPointOther"] = "other";
|
|
5
|
+
TJEntryPoint["TJEntryPointMainMenu"] = "main_manu";
|
|
6
|
+
TJEntryPoint["TJEntryPointHud"] = "hud";
|
|
7
|
+
TJEntryPoint["TJEntryPointExit"] = "exit";
|
|
8
|
+
TJEntryPoint["TJEntryPointFail"] = "fail";
|
|
9
|
+
TJEntryPoint["TJEntryPointComplete"] = "complete";
|
|
10
|
+
TJEntryPoint["TJEntryPointInbox"] = "inbox";
|
|
11
|
+
TJEntryPoint["TJEntryPointInit"] = "initialisation";
|
|
12
|
+
TJEntryPoint["TJEntryPointStore"] = "store";
|
|
13
|
+
})(TJEntryPoint || (TJEntryPoint = {}));
|
|
14
|
+
export default TJEntryPoint;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { findNodeHandle, requireNativeComponent, UIManager, } from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var Command;
|
|
4
|
+
(function (Command) {
|
|
5
|
+
Command["REQUEST_CONTENT"] = "requestContent";
|
|
6
|
+
Command["CLEAR_CONTENT"] = "clearContent";
|
|
7
|
+
})(Command || (Command = {}));
|
|
8
|
+
const TJOfferwallDiscoverNativeView = requireNativeComponent('TJOfferwallDiscoverNativeView');
|
|
9
|
+
export default class TJOfferwallDiscoverView extends React.Component {
|
|
10
|
+
nativeCompHandle = null;
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return (<TJOfferwallDiscoverNativeView {...this.props} ref={(ref) => {
|
|
16
|
+
this.nativeCompHandle = findNodeHandle(ref);
|
|
17
|
+
}}/>);
|
|
18
|
+
}
|
|
19
|
+
requestContent(placement) {
|
|
20
|
+
UIManager.dispatchViewManagerCommand(this.nativeCompHandle, Command.REQUEST_CONTENT, [placement]);
|
|
21
|
+
}
|
|
22
|
+
clearContent() {
|
|
23
|
+
UIManager.dispatchViewManagerCommand(this.nativeCompHandle, Command.CLEAR_CONTENT, []);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import TJEntryPoint from './TJEntryPoint';
|
|
4
|
+
const Tapjoy = NativeModules.TapjoyReactNativeSdk;
|
|
5
|
+
const TapjoyEmitter = new NativeEventEmitter(Tapjoy);
|
|
6
|
+
const TapjoyEventType = 'TapjoyPlacement';
|
|
7
|
+
class TJPlacement extends EventEmitter {
|
|
8
|
+
static REQUEST_DID_SUCCEED = 'requestDidSucceed';
|
|
9
|
+
static REQUEST_DID_FAIL = 'requestDidFail';
|
|
10
|
+
static CONTENT_IS_READY = 'contentIsReady';
|
|
11
|
+
static CONTENT_DID_APPEAR = 'contentDidAppear';
|
|
12
|
+
static CONTENT_DID_DISAPPEAR = 'contentDidDisappear';
|
|
13
|
+
/**
|
|
14
|
+
* Returns the name of this placement. This is the same name passed to the
|
|
15
|
+
* constructor when creating this {@link TJPlacement} object.
|
|
16
|
+
*/
|
|
17
|
+
name;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a description of the error, if any, that was encountered when processing
|
|
20
|
+
* the placement request. If the request completes successfully, this property remains
|
|
21
|
+
* undefined. You can use this property to determine why a placement request failed by
|
|
22
|
+
* listening to the {@link TJPlacement.REQUEST_DID_FAIL} event.
|
|
23
|
+
*/
|
|
24
|
+
error;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of a Tapjoy placement. Each placement is defined on the Tapjoy dashboard and can be configured
|
|
27
|
+
* to serve different content to your users.
|
|
28
|
+
*
|
|
29
|
+
* @param name - The unique identifier for this placement. It is used to register and
|
|
30
|
+
* retrieve the placement from Tapjoy.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const placement = new TJPlacement('MainMenuPlacement');
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
constructor(name) {
|
|
37
|
+
super();
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.error = undefined;
|
|
40
|
+
Tapjoy.createPlacement(this.name);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Request placement content.
|
|
44
|
+
*/
|
|
45
|
+
requestContent() {
|
|
46
|
+
const subscription = TapjoyEmitter.addListener(TapjoyEventType, (event) => {
|
|
47
|
+
if (event.name === TJPlacement.REQUEST_DID_SUCCEED) {
|
|
48
|
+
// Remove listener if there is no content available.
|
|
49
|
+
if (!this.isContentAvailable()) {
|
|
50
|
+
subscription.remove();
|
|
51
|
+
}
|
|
52
|
+
this.emit(TJPlacement.REQUEST_DID_SUCCEED, this);
|
|
53
|
+
}
|
|
54
|
+
else if (event.name === TJPlacement.REQUEST_DID_FAIL) {
|
|
55
|
+
// No more events expected, remove listener.
|
|
56
|
+
subscription.remove();
|
|
57
|
+
this.error = event.error;
|
|
58
|
+
this.emit(TJPlacement.REQUEST_DID_FAIL, this);
|
|
59
|
+
}
|
|
60
|
+
else if (event.name === TJPlacement.CONTENT_IS_READY) {
|
|
61
|
+
// No more events expected, remove listener.
|
|
62
|
+
subscription.remove();
|
|
63
|
+
this.emit(TJPlacement.CONTENT_IS_READY, this);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Tapjoy.requestPlacement(this.name);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Displays the content associated with the placement.
|
|
70
|
+
*/
|
|
71
|
+
showContent() {
|
|
72
|
+
const subscription = TapjoyEmitter.addListener(TapjoyEventType, (event) => {
|
|
73
|
+
if (event.name === TJPlacement.CONTENT_DID_APPEAR) {
|
|
74
|
+
this.emit(TJPlacement.CONTENT_DID_APPEAR, this);
|
|
75
|
+
}
|
|
76
|
+
else if (event.name === TJPlacement.CONTENT_DID_DISAPPEAR) {
|
|
77
|
+
// No more events expected, remove listener.
|
|
78
|
+
subscription.remove();
|
|
79
|
+
this.emit(TJPlacement.CONTENT_DID_DISAPPEAR, this);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
Tapjoy.showPlacement(this.name);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether the content is ready for use.
|
|
86
|
+
*
|
|
87
|
+
* @returns {boolean} True if the content is ready; otherwise, false.
|
|
88
|
+
*/
|
|
89
|
+
isContentReady() {
|
|
90
|
+
return Tapjoy.isContentReady(this.name);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Checks whether the content is available for use.
|
|
94
|
+
*
|
|
95
|
+
* @returns {boolean} True if the content is available; otherwise, false.
|
|
96
|
+
*/
|
|
97
|
+
isContentAvailable() {
|
|
98
|
+
return Tapjoy.isContentAvailable(this.name);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sets the currency balance for given currency id.
|
|
102
|
+
*
|
|
103
|
+
* @param {String} currencyId - The identifier of the currency.
|
|
104
|
+
* @param {Number} currencyBalance - The amount of the currency to set. Must be greater than or equal to 0.
|
|
105
|
+
*/
|
|
106
|
+
async setCurrencyBalance(currencyId, currencyBalance) {
|
|
107
|
+
await Tapjoy.setCurrencyBalance(currencyBalance, currencyId, this.name);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the currency balance for given currency id.
|
|
111
|
+
*
|
|
112
|
+
* @param {String} currencyId - The identifier of the currency.
|
|
113
|
+
* @return {Number} currencyBalance - The amount of the currency.
|
|
114
|
+
*/
|
|
115
|
+
async getCurrencyBalance(currencyId) {
|
|
116
|
+
return await Tapjoy.getPlacementCurrencyBalance(currencyId, this.name);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Sets the currency amount required
|
|
120
|
+
*
|
|
121
|
+
* @param {Number} amount The amount of currency the user needs. Must be greater than 0.
|
|
122
|
+
* @param {String} currencyId The identifier of the currency.
|
|
123
|
+
*/
|
|
124
|
+
async setRequiredAmount(amount, currencyId) {
|
|
125
|
+
await Tapjoy.setRequiredAmount(amount, currencyId, this.name);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets the currency amount required.
|
|
129
|
+
*
|
|
130
|
+
* @param {String} currencyId The identifier of the currency.
|
|
131
|
+
* @return {Number} The amount of currency the user needs. -1 if not available.
|
|
132
|
+
*/
|
|
133
|
+
async getRequiredAmount(currencyId) {
|
|
134
|
+
return await Tapjoy.getRequiredAmount(currencyId, this.name);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Sets the entry point for this placement instance.
|
|
138
|
+
*
|
|
139
|
+
* @param {TJEntryPoint} entryPoint - Entry point.
|
|
140
|
+
* @see TJEntryPoint
|
|
141
|
+
*/
|
|
142
|
+
setEntryPoint(entryPoint) {
|
|
143
|
+
Tapjoy.setEntryPoint(this.name, Object.values(TJEntryPoint).indexOf(entryPoint));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets the entry point for this placement instance.
|
|
147
|
+
*
|
|
148
|
+
* @returns Entry point.
|
|
149
|
+
* @see TJEntryPoint
|
|
150
|
+
*/
|
|
151
|
+
async getEntryPoint() {
|
|
152
|
+
const entryPointValue = Object.values(TJEntryPoint)[await Tapjoy.getEntryPoint(this.name)];
|
|
153
|
+
return entryPointValue;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export default TJPlacement;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
const Tapjoy = NativeModules.TapjoyReactNativeSdk;
|
|
3
|
+
class TJPrivacyPolicy {
|
|
4
|
+
async getBelowConsentAge() {
|
|
5
|
+
try {
|
|
6
|
+
let isBelowConsentAge = await Tapjoy.getBelowConsentAge();
|
|
7
|
+
return isBelowConsentAge;
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
console.error(err);
|
|
11
|
+
throw err;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async getSubjectToGDPR() {
|
|
15
|
+
try {
|
|
16
|
+
let isSubjectToGDPR = await Tapjoy.getSubjectToGDPR();
|
|
17
|
+
return isSubjectToGDPR;
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
console.error(err);
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
setUSPrivacy(usPrivacy) {
|
|
25
|
+
Tapjoy.setUSPrivacy(usPrivacy);
|
|
26
|
+
}
|
|
27
|
+
async getUSPrivacy() {
|
|
28
|
+
try {
|
|
29
|
+
let usPrivacy = await Tapjoy.getUSPrivacy();
|
|
30
|
+
return usPrivacy;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.error(err);
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async getUserConsent() {
|
|
38
|
+
try {
|
|
39
|
+
let userConsent = await Tapjoy.getUserConsent();
|
|
40
|
+
return userConsent;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(err);
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setBelowConsentAgeStatus(isBelowConsentAgeStatus) {
|
|
48
|
+
Tapjoy.setBelowConsentAgeStatus(isBelowConsentAgeStatus);
|
|
49
|
+
}
|
|
50
|
+
setSubjectToGDPRStatus(isSubjectToGDPRStatus) {
|
|
51
|
+
Tapjoy.setSubjectToGDPRStatus(isSubjectToGDPRStatus);
|
|
52
|
+
}
|
|
53
|
+
setUserConsentStatus(userConsentStatus) {
|
|
54
|
+
Tapjoy.setUserConsentStatus(userConsentStatus);
|
|
55
|
+
}
|
|
56
|
+
optOutAdvertisingID(optOut) {
|
|
57
|
+
if (Platform.OS === 'android') {
|
|
58
|
+
Tapjoy.optOutAdvertisingID(optOut);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.warn('optOutAdvertisingID is only supported on Android.');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
getOptOutAdvertisingID() {
|
|
65
|
+
if (Platform.OS === 'android') {
|
|
66
|
+
return Tapjoy.getOptOutAdvertisingID();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.warn('getOptOutAdvertisingID is only supported on Android.');
|
|
70
|
+
return Promise.resolve(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default TJPrivacyPolicy;
|