tapjoy-react-native-sdk 14.2.1 → 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.
Files changed (54) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +1 -1
  3. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +22 -1
  4. package/example/Gemfile +2 -1
  5. package/example/android/app/build.gradle +1 -1
  6. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.kt +2 -1
  7. package/example/android/build.gradle +4 -4
  8. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  9. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  10. package/example/android/gradle.properties +1 -1
  11. package/example/android/gradlew +4 -1
  12. package/example/android/gradlew.bat +2 -0
  13. package/example/package-lock.json +8605 -0
  14. package/example/package.json +9 -5
  15. package/example/src/MainScreen.tsx +33 -27
  16. package/example/src/OfferwallScreen.tsx +67 -4
  17. package/example/src/Styles.ts +13 -5
  18. package/example/src/UserProperties.tsx +13 -1
  19. package/ios/TapjoyReactNativeSdk.swift +1 -3
  20. package/lib/commonjs/TJConnect.js +5 -0
  21. package/lib/commonjs/TJEntryPoint.js +14 -0
  22. package/lib/commonjs/TJOfferwallDiscoverView.js +25 -0
  23. package/lib/commonjs/TJPlacement.js +156 -0
  24. package/lib/commonjs/TJPrivacyPolicy.js +74 -0
  25. package/lib/commonjs/TJPurchase.js +8 -0
  26. package/lib/commonjs/TJSegment.js +8 -0
  27. package/lib/commonjs/TJStatus.js +7 -0
  28. package/lib/commonjs/TJUtil.js +14 -0
  29. package/lib/commonjs/TJVersion.js +14 -0
  30. package/lib/commonjs/Tapjoy.js +212 -0
  31. package/lib/commonjs/TapjoyEvent.js +1 -0
  32. package/lib/commonjs/index.js +10 -0
  33. package/lib/typescript/TJConnect.d.ts +4 -0
  34. package/lib/typescript/TJEntryPoint.d.ts +13 -0
  35. package/lib/typescript/TJOfferwallDiscoverView.d.ts +17 -0
  36. package/lib/typescript/TJPlacement.d.ts +96 -0
  37. package/lib/typescript/TJPrivacyPolicy.d.ts +14 -0
  38. package/lib/typescript/TJPurchase.d.ts +4 -0
  39. package/lib/typescript/TJSegment.d.ts +7 -0
  40. package/lib/typescript/TJStatus.d.ts +6 -0
  41. package/lib/typescript/TJUtil.d.ts +4 -0
  42. package/lib/typescript/TJVersion.d.ts +4 -0
  43. package/lib/typescript/Tapjoy.d.ts +148 -0
  44. package/lib/typescript/TapjoyEvent.d.ts +5 -0
  45. package/lib/typescript/index.d.ts +10 -0
  46. package/package.json +5 -4
  47. package/src/TJOfferwallDiscoverView.tsx +3 -2
  48. package/src/TJPlacement.ts +25 -3
  49. package/src/TJPrivacyPolicy.ts +9 -0
  50. package/src/TJVersion.ts +1 -1
  51. package/src/Tapjoy.ts +240 -0
  52. package/src/TapjoyEvent.ts +5 -0
  53. package/src/index.ts +1 -19
  54. package/tapjoy-react-native-sdk.podspec +1 -1
@@ -29,7 +29,7 @@ export default class TJOfferwallDiscoverView extends React.Component<TJOfferwall
29
29
  super(props);
30
30
  }
31
31
 
32
- render() {
32
+ override render () {
33
33
  return (
34
34
  <TJOfferwallDiscoverNativeView
35
35
  {...this.props}
@@ -51,7 +51,8 @@ export default class TJOfferwallDiscoverView extends React.Component<TJOfferwall
51
51
  clearContent() {
52
52
  UIManager.dispatchViewManagerCommand(
53
53
  this.nativeCompHandle!!,
54
- Command.CLEAR_CONTENT
54
+ Command.CLEAR_CONTENT,
55
+ []
55
56
  );
56
57
  }
57
58
  }
@@ -20,9 +20,31 @@ class TJPlacement extends EventEmitter {
20
20
  static readonly CONTENT_DID_APPEAR = 'contentDidAppear';
21
21
  static readonly CONTENT_DID_DISAPPEAR = 'contentDidDisappear';
22
22
 
23
+ /**
24
+ * Returns the name of this placement. This is the same name passed to the
25
+ * constructor when creating this {@link TJPlacement} object.
26
+ */
23
27
  public name: string;
28
+
29
+ /**
30
+ * Returns a description of the error, if any, that was encountered when processing
31
+ * the placement request. If the request completes successfully, this property remains
32
+ * undefined. You can use this property to determine why a placement request failed by
33
+ * listening to the {@link TJPlacement.REQUEST_DID_FAIL} event.
34
+ */
24
35
  public error: string | undefined;
25
36
 
37
+ /**
38
+ * Creates a new instance of a Tapjoy placement. Each placement is defined on the Tapjoy dashboard and can be configured
39
+ * to serve different content to your users.
40
+ *
41
+ * @param name - The unique identifier for this placement. It is used to register and
42
+ * retrieve the placement from Tapjoy.
43
+ *
44
+ * @example
45
+ * const placement = new TJPlacement('MainMenuPlacement');
46
+ *
47
+ */
26
48
  public constructor(name: string) {
27
49
  super();
28
50
  this.name = name;
@@ -99,7 +121,7 @@ class TJPlacement extends EventEmitter {
99
121
  * Sets the currency balance for given currency id.
100
122
  *
101
123
  * @param {String} currencyId - The identifier of the currency.
102
- * @param {Number} currencyBalance - The amount of the currency to set.
124
+ * @param {Number} currencyBalance - The amount of the currency to set. Must be greater than or equal to 0.
103
125
  */
104
126
  async setCurrencyBalance(
105
127
  currencyId: String,
@@ -139,7 +161,7 @@ class TJPlacement extends EventEmitter {
139
161
  }
140
162
 
141
163
  /**
142
- * Sets entry point.
164
+ * Sets the entry point for this placement instance.
143
165
  *
144
166
  * @param {TJEntryPoint} entryPoint - Entry point.
145
167
  * @see TJEntryPoint
@@ -149,7 +171,7 @@ class TJPlacement extends EventEmitter {
149
171
  }
150
172
 
151
173
  /**
152
- * Gets entry point.
174
+ * Gets the entry point for this placement instance.
153
175
  *
154
176
  * @returns Entry point.
155
177
  * @see TJEntryPoint
@@ -67,6 +67,15 @@ class TJPrivacyPolicy {
67
67
  console.warn('optOutAdvertisingID is only supported on Android.');
68
68
  }
69
69
  }
70
+
71
+ getOptOutAdvertisingID(): Promise<boolean> {
72
+ if (Platform.OS === 'android') {
73
+ return Tapjoy.getOptOutAdvertisingID();
74
+ } else {
75
+ console.warn('getOptOutAdvertisingID is only supported on Android.');
76
+ return Promise.resolve(false);
77
+ }
78
+ }
70
79
  }
71
80
 
72
81
  export default TJPrivacyPolicy;
package/src/TJVersion.ts CHANGED
@@ -1,4 +1,4 @@
1
- const REACT_LIBRARY_VERSION = '14.2.1';
1
+ const REACT_LIBRARY_VERSION = '14.3.0';
2
2
  const REACT_LIBRARY_VERSION_SUFFIX = '';
3
3
 
4
4
  export class TJVersion {
package/src/Tapjoy.ts ADDED
@@ -0,0 +1,240 @@
1
+ import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
2
+ import TJSegment from './TJSegment';
3
+ import TJConnect from './TJConnect';
4
+
5
+ const LINKING_ERROR =
6
+ `The package 'tapjoy-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
7
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
8
+ '- You rebuilt the app after installing the package\n' +
9
+ '- You are not using Expo Go\n';
10
+
11
+ const TapjoyAPI = NativeModules.TapjoyReactNativeSdk
12
+ ? NativeModules.TapjoyReactNativeSdk
13
+ : new Proxy(
14
+ {},
15
+ {
16
+ get() {
17
+ throw new Error(LINKING_ERROR);
18
+ },
19
+ }
20
+ );
21
+
22
+ class Tapjoy {
23
+
24
+ /**
25
+ * Connects to the Tapjoy Server.
26
+ *
27
+ * @param sdkKey Your Tapjoy SDK Key.
28
+ * @param flags Special connect flags.
29
+ * @param onWarning Callback for connection warning.
30
+ *
31
+ * @return true if successful or error message if failed.
32
+ */
33
+ public static async connect(sdkKey: string, flags: object, onWarning?: (message: TapjoyEvent) => void) {
34
+ const TJ = NativeModules.TapjoyReactNativeSdk;
35
+ const TapjoyEmitter = new NativeEventEmitter(TJ);
36
+ const TapjoyEventType = 'Tapjoy';
37
+ const subscription = TapjoyEmitter.addListener(
38
+ TapjoyEventType,
39
+ (event: TapjoyEvent) => {
40
+ if (event.name === TJConnect.TJC_CONNECT_WARNING) {
41
+ onWarning?.(event);
42
+ subscription.remove();
43
+ }
44
+ }
45
+ );
46
+ return await TapjoyAPI.connect(sdkKey, flags);
47
+ };
48
+
49
+ /**
50
+ * Helper function to check if SDK is initialized
51
+ *
52
+ * @return true if successful
53
+ */
54
+ public static isConnected() {
55
+ return TapjoyAPI.isConnected();
56
+ };
57
+
58
+ /**
59
+ * Gets the virtual currency data from the server for this device.
60
+ *
61
+ * @returns a map with "currencyName" and "amount" or error message if failed.
62
+ */
63
+ public static async getCurrencyBalance() {
64
+ return await TapjoyAPI.getCurrencyBalance();
65
+ }
66
+
67
+ /**
68
+ * Spends virtual currency. This can only be used for currency managed by
69
+ * Tapjoy.
70
+ *
71
+ * @param amount the amount of currency
72
+ * @return a map with "currencyName" and "amount" or error message if failed.
73
+ */
74
+ public static async spendCurrency(amount: number) {
75
+ return await TapjoyAPI.spendCurrency(amount);
76
+ }
77
+
78
+ /**
79
+ * Awards virtual currency. This can only be used for currency managed by
80
+ * Tapjoy.
81
+ *
82
+ * @param amount the amount of currency
83
+ * @return a map with "currencyName" and "amount" or error message if failed.
84
+ */
85
+ public static async awardCurrency(amount: number) {
86
+ return await TapjoyAPI.awardCurrency(amount);
87
+ }
88
+
89
+ /**
90
+ * Tracks a purchase
91
+ *
92
+ * @param currencyCode
93
+ * the currency code of price as an alphabetic currency code
94
+ * specified in ISO 4217, i.e. "USD", "KRW"
95
+ * @param price
96
+ * the price of product
97
+ */
98
+ public static trackPurchase(currencyCode: string, price: number) {
99
+ TapjoyAPI.trackPurchase(currencyCode, price);
100
+ }
101
+
102
+ /**
103
+ * Enables or disables Tapjoy logging
104
+ *
105
+ * @param enable
106
+ * set to true if logging should be enabled, false to disable
107
+ * logging
108
+ */
109
+ public static setDebugEnabled(enable: Boolean) {
110
+ TapjoyAPI.setDebugEnabled(enable);
111
+ };
112
+
113
+ /**
114
+ * Assigns a user ID for this user/device. This is used to identify the user
115
+ * in your application.
116
+ *
117
+ * This is REQUIRED for NON-MANAGED currency apps.
118
+ *
119
+ * @param userID
120
+ * user ID you wish to assign to this device
121
+ * @return the user ID if successful or error message if failed.
122
+ */
123
+ public static async setUserId(userID: string) {
124
+ return await TapjoyAPI.setUserId(userID);
125
+ }
126
+
127
+ /**
128
+ * Gets the ID of the user.
129
+ *
130
+ * @return the id of the user.
131
+ */
132
+ public static async getUserId() {
133
+ return await TapjoyAPI.getUserId();
134
+ }
135
+
136
+ /**
137
+ * Sets the level of the user.
138
+ *
139
+ * @param userLevel
140
+ * the level of the user
141
+ */
142
+ public static setUserLevel(userLevel: number) {
143
+ TapjoyAPI.setUserLevel(userLevel);
144
+ }
145
+
146
+ /**
147
+ * Gets the level of the user.
148
+ *
149
+ * @return the level of the user.
150
+ */
151
+ public static async getUserLevel() {
152
+ return await TapjoyAPI.getUserLevel();
153
+ }
154
+
155
+ /**
156
+ * Sets the maximum level of the user.
157
+ *
158
+ * @param maxUserLevel
159
+ * the maximum level
160
+ */
161
+ public static setMaxLevel(maxUserLevel: number) {
162
+ TapjoyAPI.setMaxLevel(maxUserLevel);
163
+ }
164
+
165
+ /**
166
+ * Gets the maximum level of the user.
167
+ *
168
+ * @return the maximum level
169
+ */
170
+ public static async getMaxLevel() {
171
+ return await TapjoyAPI.getMaxLevel();
172
+ }
173
+
174
+ /**
175
+ * Sets the segment of the user
176
+ *
177
+ * @param segment NON_PAYER (0), PAYER (1), VIP (2)
178
+ *
179
+ */
180
+ public static setUserSegment(segment: TJSegment) {
181
+ TapjoyAPI.setUserSegment(segment);
182
+ }
183
+
184
+ /**
185
+ * Gets the segment of the user
186
+ *
187
+ * @return userSegment NON_PAYER (0), PAYER (1), VIP (2)
188
+ *
189
+ */
190
+ public static async getUserSegment() {
191
+ return await TapjoyAPI.getUserSegment();
192
+ }
193
+
194
+ /**
195
+ * Sets tags for the user.
196
+ *
197
+ * @param tags
198
+ * the tags to be set
199
+ */
200
+ public static setUserTags(tags: string[]) {
201
+ TapjoyAPI.setUserTags(tags);
202
+ }
203
+
204
+ /**
205
+ * Returns a String set which contains tags on the user.
206
+ *
207
+ * @return list of user tags
208
+ */
209
+ public static async getUserTags() {
210
+ return TapjoyAPI.getUserTags();
211
+ }
212
+
213
+ /**
214
+ * Removes all tags from the user.
215
+ */
216
+ public static clearUserTags() {
217
+ TapjoyAPI.clearUserTags();
218
+ }
219
+
220
+ /**
221
+ * Adds the given tag to the user if it is not already present.
222
+ *
223
+ * @param tag
224
+ * the tag to be added
225
+ */
226
+ public static addUserTag(tag: string) {
227
+ TapjoyAPI.addUserTag(tag);
228
+ }
229
+
230
+ /**
231
+ * Removes the given tag from the user if it is present.
232
+ *
233
+ * @param tag
234
+ * the tag to be removed
235
+ */
236
+ public static removeUserTag(tag: string) {
237
+ TapjoyAPI.removeUserTag(tag);
238
+ }
239
+ }
240
+ export default Tapjoy;
@@ -0,0 +1,5 @@
1
+ interface TapjoyEvent {
2
+ name: string;
3
+ code: string;
4
+ message: string;
5
+ }
package/src/index.ts CHANGED
@@ -1,29 +1,12 @@
1
- import { NativeModules, Platform } from 'react-native';
2
1
  import TJPlacement from './TJPlacement';
3
2
  import TJPrivacyPolicy from './TJPrivacyPolicy';
4
3
  import TJVersion from './TJVersion';
5
4
  import TJStatus from './TJStatus';
6
5
  import TJSegment from './TJSegment';
7
6
  import TJOfferwallDiscoverView from './TJOfferwallDiscoverView';
8
- import TJConnect from './TJConnect';
9
7
  import TJPurchase from './TJPurchase';
8
+ import Tapjoy from './Tapjoy';
10
9
 
11
- const LINKING_ERROR =
12
- `The package 'tapjoy-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
13
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
14
- '- You rebuilt the app after installing the package\n' +
15
- '- You are not using Expo Go\n';
16
-
17
- const Tapjoy = NativeModules.TapjoyReactNativeSdk
18
- ? NativeModules.TapjoyReactNativeSdk
19
- : new Proxy(
20
- {},
21
- {
22
- get() {
23
- throw new Error(LINKING_ERROR);
24
- },
25
- }
26
- );
27
10
 
28
11
  export {
29
12
  Tapjoy,
@@ -33,7 +16,6 @@ export {
33
16
  TJStatus,
34
17
  TJSegment,
35
18
  TJOfferwallDiscoverView,
36
- TJConnect,
37
19
  TJPurchase,
38
20
  };
39
21
  export default Tapjoy;
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency "TapjoySDK", "14.2.1"
20
+ s.dependency "TapjoySDK", "14.3.0"
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then