@adjoe/react-native-adjoe-sdk 0.0.0-stage → 5.1.3
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/README.md +33 -2
- package/android/build.gradle +93 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/BasicUtil.kt +361 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/ErrorsUtil.kt +113 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeProtectionImpl.kt +150 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeStudioImpl.kt +313 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkImpl.kt +173 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkPackage.kt +55 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/StudioUtil.kt +421 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/Util.kt +40 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +25 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +57 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +66 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +29 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +68 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +83 -0
- package/ios/AdjoeSdk.xcodeproj/project.pbxproj +281 -0
- package/ios/AdjoeSdk.xcodeproj/xcuserdata/hamid.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/AdjoeSdk.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/ErrorsUtil.swift +180 -0
- package/ios/PlaytimeProtectionImpl.swift +20 -0
- package/ios/PlaytimeSdkImpl.swift +173 -0
- package/ios/PlaytimeStudioImpl.swift +272 -0
- package/ios/RNPlaytimeBasic.mm +187 -0
- package/ios/RNPlaytimeHelpers.h +21 -0
- package/ios/RNPlaytimeHelpers.m +94 -0
- package/ios/RNPlaytimeProtection.mm +77 -0
- package/ios/RNPlaytimeStudio.mm +265 -0
- package/package.json +35 -4
- package/react-native-adjoe-sdk.podspec +30 -0
- package/src/Playtime.js +158 -0
- package/src/PlaytimeException.js +140 -0
- package/src/PlaytimeProtection.js +40 -0
- package/src/PlaytimeStudio.js +110 -0
- package/src/index.js +8 -0
- package/src/specs/NativePlaytimeProtection.ts +9 -0
- package/src/specs/NativePlaytimeStudio.ts +23 -0
- package/src/specs/NativeRNPlaytimeSdk.ts +17 -0
- package/src-ts/Playtime.d.ts +407 -0
- package/src-ts/PlaytimeException.d.ts +87 -0
- package/src-ts/PlaytimeProtection.d.ts +106 -0
- package/src-ts/PlaytimeStudio.d.ts +818 -0
- package/src-ts/index.d.ts +8 -0
- package/tsconfig.json +114 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The actionable category of a `PlaytimeException`.
|
|
3
|
+
*
|
|
4
|
+
* These are the values sent by the native layer. Any value the JS layer does
|
|
5
|
+
* not recognize is normalized to `UNKNOWN`.
|
|
6
|
+
*/
|
|
7
|
+
export const PlaytimeErrorType = Object.freeze({
|
|
8
|
+
/** Transport-layer failure (timeout, DNS, SSL, connect). */
|
|
9
|
+
NETWORK: 'NETWORK',
|
|
10
|
+
/** Network failure attributed to an active VPN. */
|
|
11
|
+
NETWORK_VPN: 'NETWORK_VPN',
|
|
12
|
+
/** The server responded with a non-2xx status. */
|
|
13
|
+
API: 'API',
|
|
14
|
+
/** The response body could not be parsed or had an unexpected shape. */
|
|
15
|
+
RESPONSE_FORMAT: 'RESPONSE_FORMAT',
|
|
16
|
+
/** SDK misconfiguration / integration error. */
|
|
17
|
+
SDK_CONFIG: 'SDK_CONFIG',
|
|
18
|
+
/** Fallback category for uncategorized errors. */
|
|
19
|
+
UNKNOWN: 'UNKNOWN',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The unified error type for all Playtime rejected promises.
|
|
24
|
+
*
|
|
25
|
+
* Every promise-returning Playtime method rejects with an instance of this
|
|
26
|
+
* class, so publishers can branch on `errorType` / `isRetryable` instead of
|
|
27
|
+
* parsing error strings:
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* try {
|
|
31
|
+
* await PlaytimeStudio.getCampaigns(options);
|
|
32
|
+
* } catch (e) {
|
|
33
|
+
* if (isPlaytimeException(e) && e.errorType === PlaytimeErrorType.NETWORK && e.isRetryable) {
|
|
34
|
+
* // retry
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class PlaytimeException extends Error {
|
|
40
|
+
constructor(message, { code, errorType, isRetryable, cause } = {}) {
|
|
41
|
+
super(message);
|
|
42
|
+
|
|
43
|
+
this.name = 'PlaytimeException';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A stable, publisher-parsable error code.
|
|
47
|
+
* @type {string|null}
|
|
48
|
+
*/
|
|
49
|
+
this.code = code != null ? code : null;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The actionable category of the error.
|
|
53
|
+
* @type {string}
|
|
54
|
+
*/
|
|
55
|
+
this.errorType = normalizeErrorType(errorType);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Flag indicating whether the failed operation is worth retrying. Defaults to false.
|
|
59
|
+
* @type {boolean}
|
|
60
|
+
*/
|
|
61
|
+
this.isRetryable = isRetryable === true;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The original error raised by the bridge, kept for debugging.
|
|
65
|
+
* @type {Error|undefined}
|
|
66
|
+
*/
|
|
67
|
+
if (cause !== undefined) {
|
|
68
|
+
this.cause = cause;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Preserve the bridge's native stack information when available.
|
|
72
|
+
if (cause != null) {
|
|
73
|
+
if (cause.stack) {
|
|
74
|
+
this.stack = cause.stack;
|
|
75
|
+
}
|
|
76
|
+
if (cause.nativeStackAndroid) {
|
|
77
|
+
this.nativeStackAndroid = cause.nativeStackAndroid;
|
|
78
|
+
}
|
|
79
|
+
if (cause.nativeStackIOS) {
|
|
80
|
+
this.nativeStackIOS = cause.nativeStackIOS;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Required so `instanceof` works when this file is transpiled down to ES5.
|
|
85
|
+
if (Object.setPrototypeOf) {
|
|
86
|
+
Object.setPrototypeOf(this, PlaytimeException.prototype);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Normalizes an error raised by the native bridge into a `PlaytimeException`.
|
|
92
|
+
*
|
|
93
|
+
* The native layer sends the structured fields in `userInfo`. Anything
|
|
94
|
+
* missing or unrecognized falls back to `UNKNOWN` / `false` / `null` so a
|
|
95
|
+
* malformed rejection can never produce an undefined `errorType`.
|
|
96
|
+
*
|
|
97
|
+
* @param {any} error the raw error from a rejected bridge promise.
|
|
98
|
+
* @returns {PlaytimeException}
|
|
99
|
+
*/
|
|
100
|
+
static from(error) {
|
|
101
|
+
if (error instanceof PlaytimeException) {
|
|
102
|
+
return error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const userInfo = (error && error.userInfo) || {};
|
|
106
|
+
const message =
|
|
107
|
+
(error && error.message) || 'Unknown error occurred';
|
|
108
|
+
|
|
109
|
+
return new PlaytimeException(message, {
|
|
110
|
+
code: userInfo.code,
|
|
111
|
+
errorType: userInfo.errorType,
|
|
112
|
+
isRetryable: userInfo.isRetryable,
|
|
113
|
+
cause: error,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Type guard for `PlaytimeException`.
|
|
120
|
+
*
|
|
121
|
+
* @param {any} error
|
|
122
|
+
* @returns {boolean}
|
|
123
|
+
*/
|
|
124
|
+
export const isPlaytimeException = (error) => error instanceof PlaytimeException;
|
|
125
|
+
|
|
126
|
+
const normalizeErrorType = (errorType) =>
|
|
127
|
+
typeof errorType === 'string' && Object.prototype.hasOwnProperty.call(PlaytimeErrorType, errorType)
|
|
128
|
+
? errorType
|
|
129
|
+
: PlaytimeErrorType.UNKNOWN;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Wraps a bridge promise so it rejects with a `PlaytimeException`.
|
|
133
|
+
*
|
|
134
|
+
* @param {Promise<any>} promise
|
|
135
|
+
* @returns {Promise<any>}
|
|
136
|
+
*/
|
|
137
|
+
export const wrapPlaytimePromise = (promise) =>
|
|
138
|
+
Promise.resolve(promise).catch((error) => {
|
|
139
|
+
throw PlaytimeException.from(error);
|
|
140
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import PlaytimeProtectionSpec from './specs/NativePlaytimeProtection';
|
|
2
|
+
import { wrapPlaytimePromise } from './PlaytimeException';
|
|
3
|
+
|
|
4
|
+
export const FaceVerificationResult = Object.freeze({
|
|
5
|
+
SUCCESS: 'SUCCESS',
|
|
6
|
+
ALREADY_VERIFIED: 'ALREADY_VERIFIED',
|
|
7
|
+
CANCELLED: 'CANCELLED',
|
|
8
|
+
NOT_INITIALIZED: 'NOT_INITIALIZED',
|
|
9
|
+
TOS_NOT_ACCEPTED: 'TOS_NOT_ACCEPTED',
|
|
10
|
+
LIVENESS_CHECK_FAILED: 'LIVENESS_CHECK_FAILED',
|
|
11
|
+
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
12
|
+
MAX_ATTEMPTS_REACHED: 'MAX_ATTEMPTS_REACHED',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const FaceVerificationStatus = Object.freeze({
|
|
16
|
+
VERIFIED: 'VERIFIED',
|
|
17
|
+
NOT_VERIFIED: 'NOT_VERIFIED',
|
|
18
|
+
NOT_INITIALIZED: 'NOT_INITIALIZED',
|
|
19
|
+
TOS_NOT_ACCEPTED: 'TOS_NOT_ACCEPTED',
|
|
20
|
+
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
21
|
+
MAX_ATTEMPTS_REACHED: 'MAX_ATTEMPTS_REACHED',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const PlaytimeProtection = {
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated faceVerification is deprecated.
|
|
27
|
+
*/
|
|
28
|
+
faceVerification: function() {
|
|
29
|
+
return wrapPlaytimePromise(PlaytimeProtectionSpec.faceVerification());
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated faceVerificationStatus is deprecated.
|
|
34
|
+
*/
|
|
35
|
+
faceVerificationStatus: function() {
|
|
36
|
+
return wrapPlaytimePromise(PlaytimeProtectionSpec.faceVerificationStatus());
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default PlaytimeProtection;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import PlaytimeStudioSpec from './specs/NativePlaytimeStudio';
|
|
2
|
+
import { wrapPlaytimePromise } from './PlaytimeException';
|
|
3
|
+
import { normalizeSealedOptions } from './Playtime';
|
|
4
|
+
|
|
5
|
+
export const PlaytimeCampaignStatus = Object.freeze({
|
|
6
|
+
AVAILABLE: 0,
|
|
7
|
+
PENDING: 1,
|
|
8
|
+
INSTALLED: 2,
|
|
9
|
+
FAILED: 3,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const PlaytimeImpressionType = Object.freeze({
|
|
13
|
+
DEFAULT: 0,
|
|
14
|
+
ENGAGED: 1,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const TosConsentAction = Object.freeze({
|
|
18
|
+
ACCEPT: 0,
|
|
19
|
+
WITHDRAW: 1,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const StudioPlacement = Object.freeze({
|
|
23
|
+
Navbar: 'navbar',
|
|
24
|
+
Icon: 'icon',
|
|
25
|
+
EarnTab: 'earn_tab',
|
|
26
|
+
GameTab: 'game_tab',
|
|
27
|
+
HomePage: 'home_page',
|
|
28
|
+
NotificationInbox: 'notification_inbox',
|
|
29
|
+
Notification: 'notification',
|
|
30
|
+
MiniGame: 'mini_game',
|
|
31
|
+
OrderPage: 'order_page',
|
|
32
|
+
RedeemSection: 'redeem_section',
|
|
33
|
+
ScanReceipt: 'scan_receipt',
|
|
34
|
+
StepConverter: 'step_converter',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const DisplayFormat = Object.freeze({
|
|
38
|
+
Icon: 'icon',
|
|
39
|
+
Notification: 'notification',
|
|
40
|
+
NotificationInbox: 'notification_inbox',
|
|
41
|
+
Carousel: 'carousel',
|
|
42
|
+
CustomCatalog: 'custom_catalog',
|
|
43
|
+
Banner: 'banner',
|
|
44
|
+
Popup: 'popup',
|
|
45
|
+
Interstitial: 'interstitial',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const PlaytimeStudio = {
|
|
49
|
+
updateTosConsent: function(action) {
|
|
50
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.updateTosConsent(action));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
getCampaigns: function(campaignOptions) {
|
|
54
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.getCampaigns(normalizeSealedOptions(campaignOptions)));
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
getOfferDetails: function(tokens, campaignOptions) {
|
|
58
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.getOfferDetails(tokens, normalizeSealedOptions(campaignOptions)));
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
getInstalledCampaigns: function(options) {
|
|
62
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.getInstalledCampaigns(normalizeSealedOptions(options)));
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
openInStore: function(campaign, useInlineInstall) {
|
|
66
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.openInStore(campaign, useInlineInstall));
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
openInstalledCampaign: function(campaign) {
|
|
70
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.openInstalledCampaign(campaign));
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
showPermissionsPrompt: function() {
|
|
74
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.showPermissionsPrompt());
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
registerRewardsConnect: function() {
|
|
78
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.registerRewardsConnect());
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
resetRewardsConnect: function() {
|
|
82
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.resetRewardsConnect());
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
executeCampaignImpression: function(campaign, impressionType) {
|
|
86
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.executeCampaignImpression(campaign, impressionType));
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
executeOfferImpression: function(token, appID) {
|
|
90
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.executeOfferImpression(token, appID));
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
showCampaignDetails: function(campaign) {
|
|
94
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.showCampaignDetails(campaign));
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
showOfferDetails: function(token, appID) {
|
|
98
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.showOfferDetails(token, appID));
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
showInstalledCampaigns: function() {
|
|
102
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.showInstalledCampaigns());
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
openChatbot: function(campaign = null) {
|
|
106
|
+
return wrapPlaytimePromise(PlaytimeStudioSpec.openChatbot(campaign));
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default PlaytimeStudio;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Playtime from './Playtime';
|
|
2
|
+
export default { ...Playtime };
|
|
3
|
+
export { default as PlaytimeStudio } from './PlaytimeStudio';
|
|
4
|
+
export { default as PlaytimeProtection } from './PlaytimeProtection';
|
|
5
|
+
export * from './PlaytimeStudio';
|
|
6
|
+
export * from './PlaytimeProtection';
|
|
7
|
+
export * from './Playtime';
|
|
8
|
+
export * from './PlaytimeException';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
faceVerification(): Promise<string>;
|
|
6
|
+
faceVerificationStatus(): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('PlaytimeProtection');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
updateTosConsent(action: number): Promise<void>;
|
|
7
|
+
getCampaigns(campaignOptions: UnsafeObject): Promise<UnsafeObject>;
|
|
8
|
+
getOfferDetails(tokens: Array<string>, campaignOptions: UnsafeObject): Promise<UnsafeObject>;
|
|
9
|
+
getInstalledCampaigns(options: UnsafeObject): Promise<UnsafeObject>;
|
|
10
|
+
openInStore(campaign: UnsafeObject, useInlineInstall: boolean): Promise<void>;
|
|
11
|
+
openInstalledCampaign(campaign: UnsafeObject): Promise<void>;
|
|
12
|
+
openChatbot(campaign: UnsafeObject | null): Promise<void>;
|
|
13
|
+
resetRewardsConnect(): Promise<void>;
|
|
14
|
+
executeCampaignImpression(campaign: UnsafeObject, impressionType: number): Promise<void>;
|
|
15
|
+
executeOfferImpression(token: string, appID: string): Promise<void>;
|
|
16
|
+
registerRewardsConnect(): Promise<void>;
|
|
17
|
+
showCampaignDetails(campaign: UnsafeObject): Promise<void>;
|
|
18
|
+
showOfferDetails(token: string, appID: string): Promise<void>;
|
|
19
|
+
showInstalledCampaigns(): Promise<void>;
|
|
20
|
+
showPermissionsPrompt(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('PlaytimeStudio');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
teardown(): Promise<void>;
|
|
7
|
+
getStatus(): Promise<UnsafeObject>;
|
|
8
|
+
initPlaytime(options: UnsafeObject): Promise<void>;
|
|
9
|
+
showCatalog(catalogOptions: UnsafeObject): Promise<void>;
|
|
10
|
+
executeImpressionEvent(catalogPlacement: UnsafeObject): Promise<void>;
|
|
11
|
+
addEventListener(): Promise<void>;
|
|
12
|
+
removeEventListener(): Promise<void>;
|
|
13
|
+
addListener(eventName: string): void;
|
|
14
|
+
removeListeners(count: number): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNPlaytimeSdk');
|