tapjoy-react-native-sdk 14.5.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 (42) hide show
  1. package/android/build.gradle +6 -13
  2. package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +21 -16
  3. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +112 -74
  4. package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkPackage.kt +29 -5
  5. package/example/android/app/build.gradle +1 -1
  6. package/example/ios/Podfile +2 -1
  7. package/example/ios/TapjoyReactNativeSdkExample/Info.plist +2 -0
  8. package/example/package.json +4 -2
  9. package/example/scripts/set-arch.sh +25 -0
  10. package/example/src/MainScreen.tsx +1 -0
  11. package/example/src/UserProperties.tsx +20 -1
  12. package/ios/TJOfferwallDiscoverNativeViewManager.m +11 -1
  13. package/ios/TJOfferwallDiscoverNativeViewManager.swift +2 -2
  14. package/ios/TapjoyReactNativeSdk.m +36 -15
  15. package/ios/TapjoyReactNativeSdk.swift +24 -4
  16. package/lib/commonjs/NativeTapjoyReactNativeSdk.js +2 -0
  17. package/lib/commonjs/TJOfferwallDiscoverView.js +43 -16
  18. package/lib/commonjs/TJOfferwallDiscoverViewNativeComponent.js +6 -0
  19. package/lib/commonjs/TJPlacement.js +17 -13
  20. package/lib/commonjs/TJPrivacyPolicy.js +81 -11
  21. package/lib/commonjs/TJVersion.js +1 -1
  22. package/lib/commonjs/Tapjoy.js +16 -10
  23. package/lib/commonjs/index.js +2 -1
  24. package/lib/commonjs/utils/ArchitectureDetection.js +7 -0
  25. package/lib/typescript/NativeTapjoyReactNativeSdk.d.ts +53 -0
  26. package/lib/typescript/TJOfferwallDiscoverView.d.ts +3 -12
  27. package/lib/typescript/TJOfferwallDiscoverViewNativeComponent.d.ts +21 -0
  28. package/lib/typescript/TJPrivacyPolicy.d.ts +29 -1
  29. package/lib/typescript/Tapjoy.d.ts +1 -1
  30. package/lib/typescript/index.d.ts +5 -3
  31. package/lib/typescript/utils/ArchitectureDetection.d.ts +5 -0
  32. package/package.json +7 -2
  33. package/src/NativeTapjoyReactNativeSdk.ts +117 -0
  34. package/src/TJOfferwallDiscoverView.tsx +56 -39
  35. package/src/TJOfferwallDiscoverViewNativeComponent.ts +37 -0
  36. package/src/TJPlacement.ts +17 -13
  37. package/src/TJPrivacyPolicy.ts +84 -12
  38. package/src/TJVersion.ts +1 -1
  39. package/src/Tapjoy.ts +20 -13
  40. package/src/index.ts +13 -3
  41. package/src/utils/ArchitectureDetection.ts +14 -0
  42. package/tapjoy-react-native-sdk.podspec +1 -1
@@ -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.5.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.5.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