tapjoy-react-native-sdk 14.4.0 → 14.6.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 +8 -15
  2. package/android/gradle.properties +3 -3
  3. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeView.kt +2 -2
  4. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +21 -16
  5. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +130 -87
  6. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkPackage.kt +29 -5
  7. package/example/android/app/build.gradle +1 -1
  8. package/example/android/app/src/main/java/com/tapjoyreactnativesdkexample/MainApplication.kt +2 -8
  9. package/example/android/build.gradle +4 -4
  10. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  11. package/example/android/gradle.properties +5 -0
  12. package/example/ios/Podfile +2 -1
  13. package/example/ios/TapjoyReactNativeSdkExample/Info.plist +3 -1
  14. package/example/ios/TapjoyReactNativeSdkExample.xcodeproj/project.pbxproj +0 -45
  15. package/example/metro.config.js +9 -15
  16. package/example/package.json +19 -16
  17. package/example/scripts/set-arch.sh +25 -0
  18. package/example/src/App.tsx +1 -2
  19. package/example/src/MainScreen.tsx +76 -60
  20. package/example/src/OfferwallDiscoverScreen.tsx +105 -91
  21. package/example/src/OfferwallScreen.tsx +170 -156
  22. package/example/src/Styles.ts +3 -2
  23. package/example/src/UserProperties.tsx +170 -136
  24. package/ios/TJOfferwallDiscoverNativeViewManager.m +11 -1
  25. package/ios/TJOfferwallDiscoverNativeViewManager.swift +2 -2
  26. package/ios/TapjoyReactNativeSdk.m +36 -15
  27. package/ios/TapjoyReactNativeSdk.swift +24 -4
  28. package/lib/commonjs/NativeTapjoyReactNativeSdk.js +2 -0
  29. package/lib/commonjs/TJOfferwallDiscoverView.js +43 -16
  30. package/lib/commonjs/TJOfferwallDiscoverViewNativeComponent.js +6 -0
  31. package/lib/commonjs/TJPlacement.js +17 -13
  32. package/lib/commonjs/TJPrivacyPolicy.js +81 -11
  33. package/lib/commonjs/TJVersion.js +1 -1
  34. package/lib/commonjs/Tapjoy.js +16 -10
  35. package/lib/commonjs/index.js +2 -1
  36. package/lib/commonjs/utils/ArchitectureDetection.js +7 -0
  37. package/lib/typescript/NativeTapjoyReactNativeSdk.d.ts +53 -0
  38. package/lib/typescript/TJOfferwallDiscoverView.d.ts +3 -12
  39. package/lib/typescript/TJOfferwallDiscoverViewNativeComponent.d.ts +21 -0
  40. package/lib/typescript/TJPrivacyPolicy.d.ts +29 -1
  41. package/lib/typescript/Tapjoy.d.ts +1 -1
  42. package/lib/typescript/index.d.ts +5 -3
  43. package/lib/typescript/utils/ArchitectureDetection.d.ts +5 -0
  44. package/package.json +14 -16
  45. package/src/NativeTapjoyReactNativeSdk.ts +117 -0
  46. package/src/TJOfferwallDiscoverView.tsx +56 -39
  47. package/src/TJOfferwallDiscoverViewNativeComponent.ts +37 -0
  48. package/src/TJPlacement.ts +17 -13
  49. package/src/TJPrivacyPolicy.ts +84 -12
  50. package/src/TJVersion.ts +1 -1
  51. package/src/Tapjoy.ts +20 -13
  52. package/src/index.ts +13 -3
  53. package/src/utils/ArchitectureDetection.ts +14 -0
  54. package/tapjoy-react-native-sdk.podspec +1 -1
@@ -0,0 +1,117 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ connect(sdkKey: string, connectFlags: Object): Promise<boolean>;
6
+
7
+ isConnected(): boolean;
8
+
9
+ setLoggingLevel(loggingLevel: number): void;
10
+
11
+ getLoggingLevel(): Promise<number>;
12
+
13
+ setUserId(userId?: string): Promise<string>;
14
+
15
+ getUserId(): Promise<string>;
16
+
17
+ setUserLevel(userLevel: number): void;
18
+
19
+ getUserLevel(): Promise<number>;
20
+
21
+ setMaxLevel(maxLevel: number): void;
22
+
23
+ getMaxLevel(): Promise<number>;
24
+
25
+ setUserSegment(userSegment: number): void;
26
+
27
+ getUserSegment(): Promise<number>;
28
+
29
+ setUserTags(tags: Array<string>): void;
30
+
31
+ getUserTags(): Promise<Array<string>>;
32
+
33
+ clearUserTags(): void;
34
+
35
+ addUserTag(tag: string): void;
36
+
37
+ removeUserTag(tag: string): void;
38
+
39
+ setCustomParameter(customParameter: string): void;
40
+
41
+ getCustomParameter(): Promise<string>;
42
+
43
+ getCurrencyBalance(): Promise<Object>;
44
+
45
+ spendCurrency(amount: number): Promise<Object>;
46
+
47
+ awardCurrency(amount: number): Promise<Object>;
48
+
49
+ createPlacement(name: string): void;
50
+
51
+ requestPlacement(name: string): void;
52
+
53
+ showPlacement(name: string): void;
54
+
55
+ isContentReady(name: string): boolean;
56
+
57
+ isContentAvailable(name: string): boolean;
58
+
59
+ setEntryPoint(name: string, entryPoint: number): void;
60
+
61
+ getEntryPoint(name: string): Promise<number>;
62
+
63
+ setCurrencyBalance(
64
+ amount: number,
65
+ currencyId: string,
66
+ placementName: string
67
+ ): Promise<Object>;
68
+
69
+ getPlacementCurrencyBalance(
70
+ currencyId: string,
71
+ placementName: string
72
+ ): Promise<number>;
73
+
74
+ setRequiredAmount(
75
+ requiredAmount: number,
76
+ currencyId: string,
77
+ placementName: string
78
+ ): Promise<Object>;
79
+
80
+ getRequiredAmount(
81
+ currencyId: string,
82
+ placementName: string
83
+ ): Promise<number>;
84
+
85
+ trackPurchase(currencyCode: string, price: number): void;
86
+
87
+ setSubjectToGDPRStatus(gdprApplicableStatus: number): void;
88
+
89
+ getBelowConsentAge(): Promise<number>;
90
+
91
+ getSubjectToGDPR(): Promise<number>;
92
+
93
+ getUserConsent(): Promise<number>;
94
+
95
+ getUSPrivacy(): Promise<string>;
96
+
97
+ setBelowConsentAgeStatus(isBelowConsentAgeStatus: number): void;
98
+
99
+ setUSPrivacy(privacyValue: string): void;
100
+
101
+ setUserConsentStatus(userConsentStatus: number): void;
102
+
103
+ getUsageStatsConsent(): Promise<number>;
104
+
105
+ setUsageStatsConsent(usageStatsConsent: number): void;
106
+
107
+ optOutAdvertisingID(optOut: boolean): void;
108
+
109
+ getOptOutAdvertisingID(): Promise<boolean>;
110
+
111
+ addListener(eventName: string): void;
112
+
113
+ removeListeners(count: number): void;
114
+ }
115
+
116
+ export default TurboModuleRegistry.get<Spec>('TapjoyReactNativeSdk');
117
+
@@ -1,58 +1,75 @@
1
- import {
2
- findNodeHandle,
3
- requireNativeComponent,
4
- UIManager,
5
- ViewStyle,
6
- } from 'react-native';
1
+ import { findNodeHandle, requireNativeComponent, UIManager } from 'react-native';
7
2
  import React from 'react';
3
+ import type { HostComponent } from 'react-native';
4
+ import type { TJOfferwallDiscoverViewProps as FabricProps } from './TJOfferwallDiscoverViewNativeComponent';
5
+ import { isFabricEnabled } from './utils/ArchitectureDetection';
8
6
 
9
- enum Command {
10
- REQUEST_CONTENT = 'requestContent',
11
- CLEAR_CONTENT = 'clearContent',
12
- }
7
+ type FabricModule = typeof import('./TJOfferwallDiscoverViewNativeComponent');
13
8
 
14
- const TJOfferwallDiscoverNativeView = requireNativeComponent(
15
- 'TJOfferwallDiscoverNativeView'
16
- );
9
+ let fabricModule: FabricModule | null = null;
10
+ let legacyComponent: HostComponent<FabricProps> | null = null;
17
11
 
18
- interface TJOfferwallDiscoverViewProps {
19
- style?: ViewStyle;
20
- onRequestSuccess?: Function;
21
- onRequestFailure?: Function;
22
- onContentReady?: Function;
23
- onContentError?: Function;
24
- }
12
+ const getFabricModule = (): FabricModule => {
13
+ if (fabricModule == null) {
14
+ fabricModule = require('./TJOfferwallDiscoverViewNativeComponent');
15
+ }
16
+ return fabricModule!;
17
+ };
18
+
19
+ const getLegacyComponent = (): HostComponent<FabricProps> => {
20
+ if (legacyComponent == null) {
21
+ legacyComponent = requireNativeComponent('TJOfferwallDiscoverNativeView');
22
+ }
23
+ return legacyComponent;
24
+ };
25
25
 
26
- export default class TJOfferwallDiscoverView extends React.Component<TJOfferwallDiscoverViewProps> {
27
- nativeCompHandle: number | null = null;
28
- constructor(props: TJOfferwallDiscoverViewProps) {
29
- super(props);
26
+ const getNativeComponent = (): HostComponent<FabricProps> => {
27
+ if (isFabricEnabled()) {
28
+ return getFabricModule().default as HostComponent<FabricProps>;
30
29
  }
30
+ return getLegacyComponent();
31
+ };
32
+
33
+ export default class TJOfferwallDiscoverView extends React.Component<FabricProps> {
34
+ private viewRef = React.createRef<React.ComponentRef<ReturnType<typeof getNativeComponent>>>();
31
35
 
32
- override render () {
36
+ override render() {
37
+ const NativeComponent = getNativeComponent();
33
38
  return (
34
- <TJOfferwallDiscoverNativeView
39
+ <NativeComponent
35
40
  {...this.props}
36
- ref={(ref) => {
37
- this.nativeCompHandle = findNodeHandle(ref);
38
- }}
41
+ ref={this.viewRef}
39
42
  />
40
43
  );
41
44
  }
42
45
 
43
46
  requestContent(placement: string) {
44
- UIManager.dispatchViewManagerCommand(
45
- this.nativeCompHandle!!,
46
- Command.REQUEST_CONTENT,
47
- [placement]
48
- );
47
+ if (isFabricEnabled() && this.viewRef.current) {
48
+ getFabricModule().Commands.requestContent(this.viewRef.current, placement);
49
+ } else {
50
+ const nodeHandle = findNodeHandle(this.viewRef.current);
51
+ if (nodeHandle != null) {
52
+ UIManager.dispatchViewManagerCommand(
53
+ nodeHandle,
54
+ 'requestContent',
55
+ [placement]
56
+ );
57
+ }
58
+ }
49
59
  }
50
60
 
51
61
  clearContent() {
52
- UIManager.dispatchViewManagerCommand(
53
- this.nativeCompHandle!!,
54
- Command.CLEAR_CONTENT,
55
- []
56
- );
62
+ if (isFabricEnabled() && this.viewRef.current) {
63
+ getFabricModule().Commands.clearContent(this.viewRef.current);
64
+ } else {
65
+ const nodeHandle = findNodeHandle(this.viewRef.current);
66
+ if (nodeHandle != null) {
67
+ UIManager.dispatchViewManagerCommand(
68
+ nodeHandle,
69
+ 'clearContent',
70
+ []
71
+ );
72
+ }
73
+ }
57
74
  }
58
75
  }
@@ -0,0 +1,37 @@
1
+ import type { ViewProps, HostComponent } from 'react-native';
2
+ import type React from 'react';
3
+ import type { BubblingEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
4
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
5
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
6
+
7
+ export interface OfferwallDiscoverEventData {
8
+ result?: string;
9
+ errorCode?: Int32;
10
+ errorMessage?: string;
11
+ }
12
+
13
+ export interface TJOfferwallDiscoverViewProps extends ViewProps {
14
+ onRequestSuccess?: BubblingEventHandler<OfferwallDiscoverEventData>;
15
+ onRequestFailure?: BubblingEventHandler<OfferwallDiscoverEventData>;
16
+ onContentReady?: BubblingEventHandler<OfferwallDiscoverEventData>;
17
+ onContentError?: BubblingEventHandler<OfferwallDiscoverEventData>;
18
+ }
19
+
20
+ export interface NativeCommands {
21
+ requestContent: (
22
+ viewRef: React.ElementRef<HostComponent<TJOfferwallDiscoverViewProps>>,
23
+ placement: string
24
+ ) => void;
25
+ clearContent: (
26
+ viewRef: React.ElementRef<HostComponent<TJOfferwallDiscoverViewProps>>
27
+ ) => void;
28
+ }
29
+
30
+ export const Commands = codegenNativeCommands<NativeCommands>({
31
+ supportedCommands: ['requestContent', 'clearContent'],
32
+ });
33
+
34
+ export default codegenNativeComponent<TJOfferwallDiscoverViewProps>(
35
+ 'TJOfferwallDiscoverNativeView'
36
+ ) as HostComponent<TJOfferwallDiscoverViewProps>;
37
+
@@ -1,9 +1,13 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native';
2
2
  import { EventEmitter } from 'eventemitter3';
3
3
  import TJEntryPoint from './TJEntryPoint';
4
+ import NativeTapjoyReactNativeSdk from './NativeTapjoyReactNativeSdk';
5
+ import { isTurboModuleEnabled } from './utils/ArchitectureDetection';
4
6
 
5
- const Tapjoy = NativeModules.TapjoyReactNativeSdk;
6
- const TapjoyEmitter = new NativeEventEmitter(Tapjoy);
7
+ const TapjoyNative = isTurboModuleEnabled()
8
+ ? (NativeTapjoyReactNativeSdk as any)
9
+ : NativeModules.TapjoyReactNativeSdk;
10
+ const TapjoyEmitter = new NativeEventEmitter(TapjoyNative);
7
11
 
8
12
  const TapjoyEventType = 'TapjoyPlacement';
9
13
 
@@ -49,7 +53,7 @@ class TJPlacement extends EventEmitter {
49
53
  super();
50
54
  this.name = name;
51
55
  this.error = undefined;
52
- Tapjoy.createPlacement(this.name);
56
+ TapjoyNative.createPlacement(this.name);
53
57
  }
54
58
 
55
59
  /**
@@ -77,7 +81,7 @@ class TJPlacement extends EventEmitter {
77
81
  }
78
82
  }
79
83
  );
80
- Tapjoy.requestPlacement(this.name);
84
+ TapjoyNative.requestPlacement(this.name);
81
85
  }
82
86
 
83
87
  /**
@@ -96,7 +100,7 @@ class TJPlacement extends EventEmitter {
96
100
  }
97
101
  }
98
102
  );
99
- Tapjoy.showPlacement(this.name);
103
+ TapjoyNative.showPlacement(this.name);
100
104
  }
101
105
 
102
106
  /**
@@ -105,7 +109,7 @@ class TJPlacement extends EventEmitter {
105
109
  * @returns {boolean} True if the content is ready; otherwise, false.
106
110
  */
107
111
  isContentReady(): boolean {
108
- return Tapjoy.isContentReady(this.name);
112
+ return TapjoyNative.isContentReady(this.name);
109
113
  }
110
114
 
111
115
  /**
@@ -114,7 +118,7 @@ class TJPlacement extends EventEmitter {
114
118
  * @returns {boolean} True if the content is available; otherwise, false.
115
119
  */
116
120
  isContentAvailable(): boolean {
117
- return Tapjoy.isContentAvailable(this.name);
121
+ return TapjoyNative.isContentAvailable(this.name);
118
122
  }
119
123
 
120
124
  /**
@@ -127,7 +131,7 @@ class TJPlacement extends EventEmitter {
127
131
  currencyId: String,
128
132
  currencyBalance: Number
129
133
  ): Promise<void> {
130
- await Tapjoy.setCurrencyBalance(currencyBalance, currencyId, this.name);
134
+ await TapjoyNative.setCurrencyBalance(currencyBalance, currencyId, this.name);
131
135
  }
132
136
 
133
137
  /**
@@ -137,7 +141,7 @@ class TJPlacement extends EventEmitter {
137
141
  * @return {Number} currencyBalance - The amount of the currency.
138
142
  */
139
143
  async getCurrencyBalance(currencyId: String): Promise<Number> {
140
- return await Tapjoy.getPlacementCurrencyBalance(currencyId, this.name);
144
+ return await TapjoyNative.getPlacementCurrencyBalance(currencyId, this.name);
141
145
  }
142
146
 
143
147
  /**
@@ -147,7 +151,7 @@ class TJPlacement extends EventEmitter {
147
151
  * @param {String} currencyId The identifier of the currency.
148
152
  */
149
153
  async setRequiredAmount(amount: Number, currencyId: String): Promise<void> {
150
- await Tapjoy.setRequiredAmount(amount, currencyId, this.name);
154
+ await TapjoyNative.setRequiredAmount(amount, currencyId, this.name);
151
155
  }
152
156
 
153
157
  /**
@@ -157,7 +161,7 @@ class TJPlacement extends EventEmitter {
157
161
  * @return {Number} The amount of currency the user needs. -1 if not available.
158
162
  */
159
163
  async getRequiredAmount(currencyId: String): Promise<Number> {
160
- return await Tapjoy.getRequiredAmount(currencyId, this.name);
164
+ return await TapjoyNative.getRequiredAmount(currencyId, this.name);
161
165
  }
162
166
 
163
167
  /**
@@ -167,7 +171,7 @@ class TJPlacement extends EventEmitter {
167
171
  * @see TJEntryPoint
168
172
  */
169
173
  setEntryPoint(entryPoint: TJEntryPoint): void {
170
- Tapjoy.setEntryPoint(this.name, Object.values(TJEntryPoint).indexOf(entryPoint));
174
+ TapjoyNative.setEntryPoint(this.name, Object.values(TJEntryPoint).indexOf(entryPoint));
171
175
  }
172
176
 
173
177
  /**
@@ -178,7 +182,7 @@ class TJPlacement extends EventEmitter {
178
182
  */
179
183
  async getEntryPoint(): Promise<TJEntryPoint | undefined> {
180
184
  const entryPointValue: TJEntryPoint | undefined =
181
- Object.values(TJEntryPoint)[await Tapjoy.getEntryPoint(this.name)];
185
+ Object.values(TJEntryPoint)[await TapjoyNative.getEntryPoint(this.name)];
182
186
  return entryPointValue;
183
187
  }
184
188
  }
@@ -1,12 +1,32 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
- import type TJStatus from './TJStatus';
2
+ import NativeTapjoyReactNativeSdk from './NativeTapjoyReactNativeSdk';
3
+ import { isTurboModuleEnabled } from './utils/ArchitectureDetection';
4
+ import TJStatus from './TJStatus';
3
5
 
4
- const Tapjoy = NativeModules.TapjoyReactNativeSdk;
6
+
7
+ const LINKING_ERROR =
8
+ `The package 'tapjoy-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
9
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
10
+ '- You rebuilt the app after installing the package\n' +
11
+ '- You are not using Expo Go\n';
12
+
13
+ const TapjoyAPI = isTurboModuleEnabled()
14
+ ? NativeTapjoyReactNativeSdk
15
+ : NativeModules.TapjoyReactNativeSdk
16
+ ? NativeModules.TapjoyReactNativeSdk
17
+ : new Proxy(
18
+ {},
19
+ {
20
+ get() {
21
+ throw new Error(LINKING_ERROR);
22
+ },
23
+ }
24
+ );
5
25
 
6
26
  class TJPrivacyPolicy {
7
27
  async getBelowConsentAge(): Promise<TJStatus> {
8
28
  try {
9
- let isBelowConsentAge: TJStatus = await Tapjoy.getBelowConsentAge();
29
+ let isBelowConsentAge: TJStatus = await TapjoyAPI.getBelowConsentAge();
10
30
  return isBelowConsentAge;
11
31
  } catch (err) {
12
32
  console.error(err);
@@ -16,7 +36,7 @@ class TJPrivacyPolicy {
16
36
 
17
37
  async getSubjectToGDPR(): Promise<TJStatus> {
18
38
  try {
19
- let isSubjectToGDPR: TJStatus = await Tapjoy.getSubjectToGDPR();
39
+ let isSubjectToGDPR: TJStatus = await TapjoyAPI.getSubjectToGDPR();
20
40
  return isSubjectToGDPR;
21
41
  } catch (err) {
22
42
  console.error(err);
@@ -25,12 +45,12 @@ class TJPrivacyPolicy {
25
45
  }
26
46
 
27
47
  setUSPrivacy(usPrivacy: string): void {
28
- Tapjoy.setUSPrivacy(usPrivacy);
48
+ TapjoyAPI.setUSPrivacy(usPrivacy);
29
49
  }
30
50
 
31
51
  async getUSPrivacy(): Promise<string> {
32
52
  try {
33
- let usPrivacy: string = await Tapjoy.getUSPrivacy();
53
+ let usPrivacy: string = await TapjoyAPI.getUSPrivacy();
34
54
  return usPrivacy;
35
55
  } catch (err) {
36
56
  console.error(err);
@@ -40,29 +60,81 @@ class TJPrivacyPolicy {
40
60
 
41
61
  async getUserConsent(): Promise<TJStatus> {
42
62
  try {
43
- let userConsent: TJStatus = await Tapjoy.getUserConsent();
63
+ let userConsent: TJStatus = await TapjoyAPI.getUserConsent();
44
64
  return userConsent;
45
65
  } catch (err) {
46
66
  console.error(err);
47
67
  throw err;
48
68
  }
49
69
  }
70
+ /**
71
+ * WARNING: EXPERIMENTAL API - DO NOT USE IT
72
+ *
73
+ * Android only.
74
+ *
75
+ * This method is experimental and intended for internal purposes only.
76
+ *
77
+ * Returns the user's consent status for accessing Android's Usage Stats API.
78
+ *
79
+ * @return TJStatus.True if the user agrees, TJStatus.False otherwise
80
+ */
81
+ async getUsageStatsConsent(): Promise<TJStatus> {
82
+ if (Platform.OS === 'android') {
83
+ try {
84
+ return await TapjoyAPI.getUsageStatsConsent();
85
+ } catch (err) {
86
+ console.error(err);
87
+ throw err;
88
+ }
89
+ } else {
90
+ console.warn('getUsageStatsConsent is only supported on Android.');
91
+ return Promise.resolve(TJStatus.Unknown);
92
+ }
93
+ }
50
94
 
51
95
  setBelowConsentAgeStatus(isBelowConsentAgeStatus: TJStatus): void {
52
- Tapjoy.setBelowConsentAgeStatus(isBelowConsentAgeStatus);
96
+ TapjoyAPI.setBelowConsentAgeStatus(isBelowConsentAgeStatus);
53
97
  }
54
98
 
55
99
  setSubjectToGDPRStatus(isSubjectToGDPRStatus: TJStatus): void {
56
- Tapjoy.setSubjectToGDPRStatus(isSubjectToGDPRStatus);
100
+ TapjoyAPI.setSubjectToGDPRStatus(isSubjectToGDPRStatus);
57
101
  }
58
102
 
59
103
  setUserConsentStatus(userConsentStatus: TJStatus): void {
60
- Tapjoy.setUserConsentStatus(userConsentStatus);
104
+ TapjoyAPI.setUserConsentStatus(userConsentStatus);
105
+ }
106
+
107
+ /**
108
+ * WARNING: EXPERIMENTAL API - DO NOT USE IT
109
+ *
110
+ * Android only.
111
+ *
112
+ * This method is experimental and intended for internal purposes only.
113
+ *
114
+ * Sets the user's consent status for accessing Android's Usage Stats API.
115
+ * The Android Usage Stats API (UsageStatsManager) allows apps to access
116
+ * data about app usage on the device.
117
+ *
118
+ * @param usageStatsConsent TJStatus.True if the user has granted permission
119
+ * to access their usage statistics, TJStatus.False
120
+ * if they have denied or not yet granted permission.
121
+ */
122
+ setUsageStatsConsent(usageStatsConsent: TJStatus): void {
123
+ if (Platform.OS === 'android') {
124
+ try {
125
+ TapjoyAPI.setUsageStatsConsent(usageStatsConsent);
126
+ } catch (err) {
127
+ console.error(err);
128
+ throw err;
129
+ }
130
+ } else {
131
+ console.warn('setUsageStatsConsent is only supported on Android.');
132
+ }
61
133
  }
62
134
 
63
135
  optOutAdvertisingID(optOut: boolean): void {
64
136
  if (Platform.OS === 'android') {
65
- Tapjoy.optOutAdvertisingID(optOut);
137
+ TapjoyAPI.optOutAdvertisingID(optOut);
66
138
  } else {
67
139
  console.warn('optOutAdvertisingID is only supported on Android.');
68
140
  }
@@ -70,7 +142,7 @@ class TJPrivacyPolicy {
70
142
 
71
143
  getOptOutAdvertisingID(): Promise<boolean> {
72
144
  if (Platform.OS === 'android') {
73
- return Tapjoy.getOptOutAdvertisingID();
145
+ return TapjoyAPI.getOptOutAdvertisingID();
74
146
  } else {
75
147
  console.warn('getOptOutAdvertisingID is only supported on Android.');
76
148
  return Promise.resolve(false);
package/src/TJVersion.ts CHANGED
@@ -1,4 +1,4 @@
1
- const REACT_LIBRARY_VERSION = '14.4.0';
1
+ const REACT_LIBRARY_VERSION = '14.6.0';
2
2
  const REACT_LIBRARY_VERSION_SUFFIX = '';
3
3
 
4
4
  export class TJVersion {
package/src/Tapjoy.ts CHANGED
@@ -3,6 +3,8 @@ import TJSegment from './TJSegment';
3
3
  import TJConnect from './TJConnect';
4
4
  import TJLoggingLevel from './TJLoggingLevel';
5
5
  import { TapjoyEvent } from './TapjoyEvent';
6
+ import NativeTapjoyReactNativeSdk from './NativeTapjoyReactNativeSdk';
7
+ import { isTurboModuleEnabled } from './utils/ArchitectureDetection';
6
8
 
7
9
  const LINKING_ERROR =
8
10
  `The package 'tapjoy-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
@@ -10,16 +12,22 @@ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
10
12
  '- You rebuilt the app after installing the package\n' +
11
13
  '- You are not using Expo Go\n';
12
14
 
13
- const TapjoyAPI = NativeModules.TapjoyReactNativeSdk
14
- ? NativeModules.TapjoyReactNativeSdk
15
- : new Proxy(
16
- {},
17
- {
18
- get() {
19
- throw new Error(LINKING_ERROR);
20
- },
21
- }
22
- );
15
+ const TapjoyAPI = isTurboModuleEnabled()
16
+ ? NativeTapjoyReactNativeSdk
17
+ : NativeModules.TapjoyReactNativeSdk
18
+ ? NativeModules.TapjoyReactNativeSdk
19
+ : new Proxy(
20
+ {},
21
+ {
22
+ get() {
23
+ throw new Error(LINKING_ERROR);
24
+ },
25
+ }
26
+ );
27
+
28
+ const NativeModuleForEmitter: any = isTurboModuleEnabled()
29
+ ? NativeTapjoyReactNativeSdk
30
+ : NativeModules.TapjoyReactNativeSdk;
23
31
 
24
32
  class Tapjoy {
25
33
 
@@ -33,8 +41,7 @@ class Tapjoy {
33
41
  * @return true if successful or error message if failed.
34
42
  */
35
43
  public static async connect(sdkKey: string, flags: object, onWarning?: (message: TapjoyEvent) => void) {
36
- const TJ = NativeModules.TapjoyReactNativeSdk;
37
- const TapjoyEmitter = new NativeEventEmitter(TJ);
44
+ const TapjoyEmitter = new NativeEventEmitter(NativeModuleForEmitter);
38
45
  const TapjoyEventType = 'Tapjoy';
39
46
  const subscription = TapjoyEmitter.addListener(
40
47
  TapjoyEventType,
@@ -143,7 +150,7 @@ class Tapjoy {
143
150
  *
144
151
  * @param userID
145
152
  * user ID you wish to assign to this device
146
- * @return the user ID if successful or error message if failed.
153
+ * @return the user ID if successful or error message if failed.
147
154
  */
148
155
  public static async setUserId(userID: string) {
149
156
  return await TapjoyAPI.setUserId(userID);
package/src/index.ts CHANGED
@@ -7,8 +7,12 @@ import TJOfferwallDiscoverView from './TJOfferwallDiscoverView';
7
7
  import TJPurchase from './TJPurchase';
8
8
  import TJLoggingLevel from './TJLoggingLevel';
9
9
  import Tapjoy from './Tapjoy';
10
- import { TapjoyEvent } from './TapjoyEvent';
11
-
10
+ import type { TapjoyEvent } from './TapjoyEvent';
11
+ import { isTurboModuleEnabled, isFabricEnabled } from './utils/ArchitectureDetection';
12
+ import type {
13
+ OfferwallDiscoverEventData,
14
+ TJOfferwallDiscoverViewProps as TJOfferwallDiscoverViewNativeProps,
15
+ } from './TJOfferwallDiscoverViewNativeComponent';
12
16
 
13
17
  export {
14
18
  Tapjoy,
@@ -20,6 +24,12 @@ export {
20
24
  TJOfferwallDiscoverView,
21
25
  TJPurchase,
22
26
  TJLoggingLevel,
27
+ isTurboModuleEnabled,
28
+ isFabricEnabled,
29
+ };
30
+ export type {
31
+ TapjoyEvent,
32
+ OfferwallDiscoverEventData,
33
+ TJOfferwallDiscoverViewNativeProps,
23
34
  };
24
- export type { TapjoyEvent };
25
35
  export default Tapjoy;
@@ -0,0 +1,14 @@
1
+ import NativeTapjoyReactNativeSdk from '../NativeTapjoyReactNativeSdk';
2
+
3
+ declare global {
4
+ var nativeFabricUIManager: any | undefined;
5
+ }
6
+
7
+ export const isTurboModuleEnabled = (): boolean => {
8
+ return NativeTapjoyReactNativeSdk != null;
9
+ };
10
+
11
+ export const isFabricEnabled = (): boolean => {
12
+ return global.nativeFabricUIManager != null;
13
+ };
14
+
@@ -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.4.0"
20
+ s.dependency "TapjoySDK", "14.6.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