tapjoy-react-native-sdk 14.5.0 → 14.7.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 +6 -13
- package/android/src/main/java/com/tapjoyreactnativesdk/TJOfferwallDiscoverNativeViewManager.kt +21 -16
- package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkModule.kt +112 -74
- package/android/src/main/java/com/tapjoyreactnativesdk/TapjoyReactNativeSdkPackage.kt +29 -5
- package/example/android/app/build.gradle +1 -1
- package/example/ios/Podfile +2 -1
- package/example/ios/TapjoyReactNativeSdkExample/Info.plist +2 -0
- package/example/package.json +4 -2
- package/example/scripts/set-arch.sh +25 -0
- package/example/src/MainScreen.tsx +1 -0
- package/example/src/UserProperties.tsx +20 -1
- package/ios/TJOfferwallDiscoverNativeViewManager.m +11 -1
- package/ios/TJOfferwallDiscoverNativeViewManager.swift +2 -2
- package/ios/TapjoyReactNativeSdk.m +36 -15
- package/ios/TapjoyReactNativeSdk.swift +24 -4
- package/lib/commonjs/NativeTapjoyReactNativeSdk.js +2 -0
- package/lib/commonjs/TJOfferwallDiscoverView.js +43 -16
- package/lib/commonjs/TJOfferwallDiscoverViewNativeComponent.js +6 -0
- package/lib/commonjs/TJPlacement.js +17 -13
- package/lib/commonjs/TJPrivacyPolicy.js +81 -11
- package/lib/commonjs/TJVersion.js +1 -1
- package/lib/commonjs/Tapjoy.js +16 -10
- package/lib/commonjs/index.js +2 -1
- package/lib/commonjs/utils/ArchitectureDetection.js +7 -0
- package/lib/typescript/NativeTapjoyReactNativeSdk.d.ts +53 -0
- package/lib/typescript/TJOfferwallDiscoverView.d.ts +3 -12
- package/lib/typescript/TJOfferwallDiscoverViewNativeComponent.d.ts +21 -0
- package/lib/typescript/TJPrivacyPolicy.d.ts +29 -1
- package/lib/typescript/Tapjoy.d.ts +1 -1
- package/lib/typescript/index.d.ts +5 -3
- package/lib/typescript/utils/ArchitectureDetection.d.ts +5 -0
- package/package.json +7 -2
- package/src/NativeTapjoyReactNativeSdk.ts +117 -0
- package/src/TJOfferwallDiscoverView.tsx +56 -39
- package/src/TJOfferwallDiscoverViewNativeComponent.ts +37 -0
- package/src/TJPlacement.ts +17 -13
- package/src/TJPrivacyPolicy.ts +84 -12
- package/src/TJVersion.ts +1 -1
- package/src/Tapjoy.ts +20 -13
- package/src/index.ts +13 -3
- package/src/utils/ArchitectureDetection.ts +14 -0
- package/tapjoy-react-native-sdk.podspec +1 -1
package/lib/commonjs/Tapjoy.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
|
2
2
|
import TJConnect from './TJConnect';
|
|
3
3
|
import TJLoggingLevel from './TJLoggingLevel';
|
|
4
|
+
import NativeTapjoyReactNativeSdk from './NativeTapjoyReactNativeSdk';
|
|
5
|
+
import { isTurboModuleEnabled } from './utils/ArchitectureDetection';
|
|
4
6
|
const LINKING_ERROR = `The package 'tapjoy-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
7
|
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
8
|
'- You rebuilt the app after installing the package\n' +
|
|
7
9
|
'- You are not using Expo Go\n';
|
|
8
|
-
const TapjoyAPI =
|
|
9
|
-
?
|
|
10
|
-
:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const TapjoyAPI = isTurboModuleEnabled()
|
|
11
|
+
? NativeTapjoyReactNativeSdk
|
|
12
|
+
: NativeModules.TapjoyReactNativeSdk
|
|
13
|
+
? NativeModules.TapjoyReactNativeSdk
|
|
14
|
+
: new Proxy({}, {
|
|
15
|
+
get() {
|
|
16
|
+
throw new Error(LINKING_ERROR);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const NativeModuleForEmitter = isTurboModuleEnabled()
|
|
20
|
+
? NativeTapjoyReactNativeSdk
|
|
21
|
+
: NativeModules.TapjoyReactNativeSdk;
|
|
15
22
|
class Tapjoy {
|
|
16
23
|
/**
|
|
17
24
|
* Connects to the Tapjoy Server.
|
|
@@ -23,8 +30,7 @@ class Tapjoy {
|
|
|
23
30
|
* @return true if successful or error message if failed.
|
|
24
31
|
*/
|
|
25
32
|
static async connect(sdkKey, flags, onWarning) {
|
|
26
|
-
const
|
|
27
|
-
const TapjoyEmitter = new NativeEventEmitter(TJ);
|
|
33
|
+
const TapjoyEmitter = new NativeEventEmitter(NativeModuleForEmitter);
|
|
28
34
|
const TapjoyEventType = 'Tapjoy';
|
|
29
35
|
const subscription = TapjoyEmitter.addListener(TapjoyEventType, (event) => {
|
|
30
36
|
if (event.name === TJConnect.TJC_CONNECT_WARNING) {
|
|
@@ -126,7 +132,7 @@ class Tapjoy {
|
|
|
126
132
|
*
|
|
127
133
|
* @param userID
|
|
128
134
|
* user ID you wish to assign to this device
|
|
129
|
-
|
|
135
|
+
* @return the user ID if successful or error message if failed.
|
|
130
136
|
*/
|
|
131
137
|
static async setUserId(userID) {
|
|
132
138
|
return await TapjoyAPI.setUserId(userID);
|
package/lib/commonjs/index.js
CHANGED
|
@@ -7,5 +7,6 @@ import TJOfferwallDiscoverView from './TJOfferwallDiscoverView';
|
|
|
7
7
|
import TJPurchase from './TJPurchase';
|
|
8
8
|
import TJLoggingLevel from './TJLoggingLevel';
|
|
9
9
|
import Tapjoy from './Tapjoy';
|
|
10
|
-
|
|
10
|
+
import { isTurboModuleEnabled, isFabricEnabled } from './utils/ArchitectureDetection';
|
|
11
|
+
export { Tapjoy, TJPlacement, TJPrivacyPolicy, TJVersion, TJStatus, TJSegment, TJOfferwallDiscoverView, TJPurchase, TJLoggingLevel, isTurboModuleEnabled, isFabricEnabled, };
|
|
11
12
|
export default Tapjoy;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
connect(sdkKey: string, connectFlags: Object): Promise<boolean>;
|
|
4
|
+
isConnected(): boolean;
|
|
5
|
+
setLoggingLevel(loggingLevel: number): void;
|
|
6
|
+
getLoggingLevel(): Promise<number>;
|
|
7
|
+
setUserId(userId?: string): Promise<string>;
|
|
8
|
+
getUserId(): Promise<string>;
|
|
9
|
+
setUserLevel(userLevel: number): void;
|
|
10
|
+
getUserLevel(): Promise<number>;
|
|
11
|
+
setMaxLevel(maxLevel: number): void;
|
|
12
|
+
getMaxLevel(): Promise<number>;
|
|
13
|
+
setUserSegment(userSegment: number): void;
|
|
14
|
+
getUserSegment(): Promise<number>;
|
|
15
|
+
setUserTags(tags: Array<string>): void;
|
|
16
|
+
getUserTags(): Promise<Array<string>>;
|
|
17
|
+
clearUserTags(): void;
|
|
18
|
+
addUserTag(tag: string): void;
|
|
19
|
+
removeUserTag(tag: string): void;
|
|
20
|
+
setCustomParameter(customParameter: string): void;
|
|
21
|
+
getCustomParameter(): Promise<string>;
|
|
22
|
+
getCurrencyBalance(): Promise<Object>;
|
|
23
|
+
spendCurrency(amount: number): Promise<Object>;
|
|
24
|
+
awardCurrency(amount: number): Promise<Object>;
|
|
25
|
+
createPlacement(name: string): void;
|
|
26
|
+
requestPlacement(name: string): void;
|
|
27
|
+
showPlacement(name: string): void;
|
|
28
|
+
isContentReady(name: string): boolean;
|
|
29
|
+
isContentAvailable(name: string): boolean;
|
|
30
|
+
setEntryPoint(name: string, entryPoint: number): void;
|
|
31
|
+
getEntryPoint(name: string): Promise<number>;
|
|
32
|
+
setCurrencyBalance(amount: number, currencyId: string, placementName: string): Promise<Object>;
|
|
33
|
+
getPlacementCurrencyBalance(currencyId: string, placementName: string): Promise<number>;
|
|
34
|
+
setRequiredAmount(requiredAmount: number, currencyId: string, placementName: string): Promise<Object>;
|
|
35
|
+
getRequiredAmount(currencyId: string, placementName: string): Promise<number>;
|
|
36
|
+
trackPurchase(currencyCode: string, price: number): void;
|
|
37
|
+
setSubjectToGDPRStatus(gdprApplicableStatus: number): void;
|
|
38
|
+
getBelowConsentAge(): Promise<number>;
|
|
39
|
+
getSubjectToGDPR(): Promise<number>;
|
|
40
|
+
getUserConsent(): Promise<number>;
|
|
41
|
+
getUSPrivacy(): Promise<string>;
|
|
42
|
+
setBelowConsentAgeStatus(isBelowConsentAgeStatus: number): void;
|
|
43
|
+
setUSPrivacy(privacyValue: string): void;
|
|
44
|
+
setUserConsentStatus(userConsentStatus: number): void;
|
|
45
|
+
getUsageStatsConsent(): Promise<number>;
|
|
46
|
+
setUsageStatsConsent(usageStatsConsent: number): void;
|
|
47
|
+
optOutAdvertisingID(optOut: boolean): void;
|
|
48
|
+
getOptOutAdvertisingID(): Promise<boolean>;
|
|
49
|
+
addListener(eventName: string): void;
|
|
50
|
+
removeListeners(count: number): void;
|
|
51
|
+
}
|
|
52
|
+
declare const _default: Spec | null;
|
|
53
|
+
export default _default;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { ViewStyle } from 'react-native';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onRequestFailure?: Function;
|
|
7
|
-
onContentReady?: Function;
|
|
8
|
-
onContentError?: Function;
|
|
9
|
-
}
|
|
10
|
-
export default class TJOfferwallDiscoverView extends React.Component<TJOfferwallDiscoverViewProps> {
|
|
11
|
-
nativeCompHandle: number | null;
|
|
12
|
-
constructor(props: TJOfferwallDiscoverViewProps);
|
|
2
|
+
import type { TJOfferwallDiscoverViewProps as FabricProps } from './TJOfferwallDiscoverViewNativeComponent';
|
|
3
|
+
export default class TJOfferwallDiscoverView extends React.Component<FabricProps> {
|
|
4
|
+
private viewRef;
|
|
13
5
|
render(): React.JSX.Element;
|
|
14
6
|
requestContent(placement: string): void;
|
|
15
7
|
clearContent(): void;
|
|
16
8
|
}
|
|
17
|
-
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export interface OfferwallDiscoverEventData {
|
|
5
|
+
result?: string;
|
|
6
|
+
errorCode?: Int32;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TJOfferwallDiscoverViewProps extends ViewProps {
|
|
10
|
+
onRequestSuccess?: BubblingEventHandler<OfferwallDiscoverEventData>;
|
|
11
|
+
onRequestFailure?: BubblingEventHandler<OfferwallDiscoverEventData>;
|
|
12
|
+
onContentReady?: BubblingEventHandler<OfferwallDiscoverEventData>;
|
|
13
|
+
onContentError?: BubblingEventHandler<OfferwallDiscoverEventData>;
|
|
14
|
+
}
|
|
15
|
+
export interface NativeCommands {
|
|
16
|
+
requestContent: (viewRef: React.ElementRef<HostComponent<TJOfferwallDiscoverViewProps>>, placement: string) => void;
|
|
17
|
+
clearContent: (viewRef: React.ElementRef<HostComponent<TJOfferwallDiscoverViewProps>>) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const Commands: NativeCommands;
|
|
20
|
+
declare const _default: HostComponent<TJOfferwallDiscoverViewProps>;
|
|
21
|
+
export default _default;
|
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TJStatus from './TJStatus';
|
|
2
2
|
declare class TJPrivacyPolicy {
|
|
3
3
|
getBelowConsentAge(): Promise<TJStatus>;
|
|
4
4
|
getSubjectToGDPR(): Promise<TJStatus>;
|
|
5
5
|
setUSPrivacy(usPrivacy: string): void;
|
|
6
6
|
getUSPrivacy(): Promise<string>;
|
|
7
7
|
getUserConsent(): Promise<TJStatus>;
|
|
8
|
+
/**
|
|
9
|
+
* WARNING: EXPERIMENTAL API - DO NOT USE IT
|
|
10
|
+
*
|
|
11
|
+
* Android only.
|
|
12
|
+
*
|
|
13
|
+
* This method is experimental and intended for internal purposes only.
|
|
14
|
+
*
|
|
15
|
+
* Returns the user's consent status for accessing Android's Usage Stats API.
|
|
16
|
+
*
|
|
17
|
+
* @return TJStatus.True if the user agrees, TJStatus.False otherwise
|
|
18
|
+
*/
|
|
19
|
+
getUsageStatsConsent(): Promise<TJStatus>;
|
|
8
20
|
setBelowConsentAgeStatus(isBelowConsentAgeStatus: TJStatus): void;
|
|
9
21
|
setSubjectToGDPRStatus(isSubjectToGDPRStatus: TJStatus): void;
|
|
10
22
|
setUserConsentStatus(userConsentStatus: TJStatus): void;
|
|
23
|
+
/**
|
|
24
|
+
* WARNING: EXPERIMENTAL API - DO NOT USE IT
|
|
25
|
+
*
|
|
26
|
+
* Android only.
|
|
27
|
+
*
|
|
28
|
+
* This method is experimental and intended for internal purposes only.
|
|
29
|
+
*
|
|
30
|
+
* Sets the user's consent status for accessing Android's Usage Stats API.
|
|
31
|
+
* The Android Usage Stats API (UsageStatsManager) allows apps to access
|
|
32
|
+
* data about app usage on the device.
|
|
33
|
+
*
|
|
34
|
+
* @param usageStatsConsent TJStatus.True if the user has granted permission
|
|
35
|
+
* to access their usage statistics, TJStatus.False
|
|
36
|
+
* if they have denied or not yet granted permission.
|
|
37
|
+
*/
|
|
38
|
+
setUsageStatsConsent(usageStatsConsent: TJStatus): void;
|
|
11
39
|
optOutAdvertisingID(optOut: boolean): void;
|
|
12
40
|
getOptOutAdvertisingID(): Promise<boolean>;
|
|
13
41
|
}
|
|
@@ -83,7 +83,7 @@ declare class Tapjoy {
|
|
|
83
83
|
*
|
|
84
84
|
* @param userID
|
|
85
85
|
* user ID you wish to assign to this device
|
|
86
|
-
|
|
86
|
+
* @return the user ID if successful or error message if failed.
|
|
87
87
|
*/
|
|
88
88
|
static setUserId(userID: string): Promise<any>;
|
|
89
89
|
/**
|
|
@@ -7,7 +7,9 @@ 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
|
-
|
|
12
|
-
|
|
10
|
+
import type { TapjoyEvent } from './TapjoyEvent';
|
|
11
|
+
import { isTurboModuleEnabled, isFabricEnabled } from './utils/ArchitectureDetection';
|
|
12
|
+
import type { OfferwallDiscoverEventData, TJOfferwallDiscoverViewProps as TJOfferwallDiscoverViewNativeProps } from './TJOfferwallDiscoverViewNativeComponent';
|
|
13
|
+
export { Tapjoy, TJPlacement, TJPrivacyPolicy, TJVersion, TJStatus, TJSegment, TJOfferwallDiscoverView, TJPurchase, TJLoggingLevel, isTurboModuleEnabled, isFabricEnabled, };
|
|
14
|
+
export type { TapjoyEvent, OfferwallDiscoverEventData, TJOfferwallDiscoverViewNativeProps, };
|
|
13
15
|
export default Tapjoy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tapjoy-react-native-sdk",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.7.0",
|
|
4
4
|
"description": "ReactNative Plugin for Tapjoy SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
47
47
|
"example": "yarn --cwd example",
|
|
48
48
|
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
49
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build temp package",
|
|
49
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build temp package && cd example/android && ./gradlew clean",
|
|
50
50
|
"doc": "typedoc --entryPointStrategy expand src/*",
|
|
51
51
|
"postinstall": "echo 'For Android, please ensure your project’s Gradle is configured correctly. Instructions can be found at: https://dev.tapjoy.com/en/reactnative-plugin/Quickstart'"
|
|
52
52
|
},
|
|
@@ -141,5 +141,10 @@
|
|
|
141
141
|
},
|
|
142
142
|
"dependencies": {
|
|
143
143
|
"eventemitter3": "^5.0.1"
|
|
144
|
+
},
|
|
145
|
+
"codegenConfig": {
|
|
146
|
+
"name": "TapjoyReactNativeSdk",
|
|
147
|
+
"type": "all",
|
|
148
|
+
"jsSrcsDir": "src"
|
|
144
149
|
}
|
|
145
150
|
}
|
|
@@ -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
|
-
|
|
10
|
-
REQUEST_CONTENT = 'requestContent',
|
|
11
|
-
CLEAR_CONTENT = 'clearContent',
|
|
12
|
-
}
|
|
7
|
+
type FabricModule = typeof import('./TJOfferwallDiscoverViewNativeComponent');
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
9
|
+
let fabricModule: FabricModule | null = null;
|
|
10
|
+
let legacyComponent: HostComponent<FabricProps> | null = null;
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
<
|
|
39
|
+
<NativeComponent
|
|
35
40
|
{...this.props}
|
|
36
|
-
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
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
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
|
+
|
package/src/TJPlacement.ts
CHANGED
|
@@ -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
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
185
|
+
Object.values(TJEntryPoint)[await TapjoyNative.getEntryPoint(this.name)];
|
|
182
186
|
return entryPointValue;
|
|
183
187
|
}
|
|
184
188
|
}
|