apps-sdk 1.1.65 → 1.1.66
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/index.js +2 -0
- package/package.json +1 -1
- package/src/components/AdaptyOnboarding.js +208 -0
- package/src/libraries/Adapty.js +7 -0
- package/types/index.d.ts +27 -7
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice, MixPanel, Adapty, HomeActions, Facebook, Legal} from "./src/libraries";
|
|
2
2
|
import PayWall from "./src/components/PayWall";
|
|
3
|
+
import AdaptyOnboarding from "./src/components/AdaptyOnboarding";
|
|
3
4
|
|
|
4
5
|
class AppsSDK {
|
|
5
6
|
constructor() {
|
|
@@ -56,6 +57,7 @@ export default {
|
|
|
56
57
|
mixpanel: MixPanel,
|
|
57
58
|
tracking: TrackingTransparency,
|
|
58
59
|
paywall: PayWall,
|
|
60
|
+
adaptyOnboarding: AdaptyOnboarding,
|
|
59
61
|
notifications: NotificationsPush,
|
|
60
62
|
voice: Voice,
|
|
61
63
|
adapty: Adapty,
|
package/package.json
CHANGED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal } from 'react-native';
|
|
3
|
+
import { AdaptyOnboardingView } from 'react-native-adapty/dist/ui';
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import Adapty from '../libraries/Adapty';
|
|
6
|
+
import * as config from '../../config';
|
|
7
|
+
|
|
8
|
+
class AdaptyOnboarding extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
12
|
+
onboarding: null,
|
|
13
|
+
isLoading: true,
|
|
14
|
+
};
|
|
15
|
+
this.remoteConfig = null;
|
|
16
|
+
this.currentStep = 0;
|
|
17
|
+
this.totalSteps = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
const { placementID, lang } = this.props;
|
|
22
|
+
this.loadOnboarding(placementID, lang);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async componentDidUpdate(prevProps) {
|
|
26
|
+
if (this.props.visible && !prevProps.visible) {
|
|
27
|
+
const { placementID, lang } = this.props;
|
|
28
|
+
await this.loadOnboarding(placementID, lang);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
loadOnboarding = async (placementID, lang) => {
|
|
33
|
+
try {
|
|
34
|
+
this.setState({ isLoading: true });
|
|
35
|
+
const onboarding = await Adapty.getOnboardingForPlacement(placementID, lang);
|
|
36
|
+
|
|
37
|
+
if (onboarding) {
|
|
38
|
+
this.remoteConfig = onboarding.remoteConfig || {};
|
|
39
|
+
|
|
40
|
+
if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
|
|
41
|
+
config.DEBUG_MODE && console.log('Remote config loaded:', this.remoteConfig);
|
|
42
|
+
this.props.onRemoteConfigLoaded(this.remoteConfig);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.setState({ onboarding, isLoading: false });
|
|
46
|
+
} else {
|
|
47
|
+
console.log('Onboarding not found for placement:', placementID, 'and language:', lang);
|
|
48
|
+
this.setState({ isLoading: false });
|
|
49
|
+
if (this.props.onError) {
|
|
50
|
+
this.props.onError(new Error('Onboarding not found'), this.remoteConfig);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.log('Error loading onboarding:', error);
|
|
55
|
+
this.setState({ isLoading: false });
|
|
56
|
+
if (this.props.onError) {
|
|
57
|
+
this.props.onError(error, this.remoteConfig);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
63
|
+
handleCustom = (actionId, meta) => {
|
|
64
|
+
config.DEBUG_MODE && console.log('Onboarding custom AdaptyOnboarding:', actionId, meta);
|
|
65
|
+
|
|
66
|
+
if (this.props.onCustom) {
|
|
67
|
+
this.props.onCustom(actionId, meta, this.remoteConfig);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
handleClose = (actionId, meta) => {
|
|
72
|
+
const isLastStep = this.totalSteps > 0 && this.currentStep === this.totalSteps - 1;
|
|
73
|
+
|
|
74
|
+
config.DEBUG_MODE && console.log('Onboarding close attempt AdaptyOnboarding:', {actionId, meta, currentStep: this.currentStep, totalSteps: this.totalSteps, isLastStep });
|
|
75
|
+
|
|
76
|
+
if (this.props.onClose) {
|
|
77
|
+
this.props.onClose(actionId, meta, this.remoteConfig);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
handleModalDismiss = () => {
|
|
84
|
+
config.DEBUG_MODE && console.log('AdaptyOnboarding Modal fully dismissed');
|
|
85
|
+
|
|
86
|
+
// Reset state after modal is fully dismissed
|
|
87
|
+
this.currentStep = 0;
|
|
88
|
+
this.totalSteps = 0;
|
|
89
|
+
|
|
90
|
+
// Notify parent that modal is fully closed
|
|
91
|
+
if (this.props.onModalDismissed) {
|
|
92
|
+
this.props.onModalDismissed();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
handleStateUpdated = (action, meta) => {
|
|
97
|
+
if (meta && typeof meta === 'object') {
|
|
98
|
+
this.currentStep = meta.screen_index ?? this.currentStep;
|
|
99
|
+
this.totalSteps = meta.total_screens ?? this.totalSteps;
|
|
100
|
+
|
|
101
|
+
config.DEBUG_MODE && console.log('State updated AdaptyOnboarding:', {action, meta, currentStep: this.currentStep, totalSteps: this.totalSteps});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.props.onStateUpdated) {
|
|
105
|
+
this.props.onStateUpdated(action, meta, this.remoteConfig);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
handleError = (error) => {
|
|
110
|
+
console.log('Onboarding error:', error);
|
|
111
|
+
|
|
112
|
+
// Check if it's a WebResource ORB error (common on Android)
|
|
113
|
+
const isORBError = error?.message?.includes('ERR_BLOCKED_BY_ORB');
|
|
114
|
+
|
|
115
|
+
if (isORBError) {
|
|
116
|
+
config.DEBUG_MODE && console.log('WebResource ORB error detected - non-critical, continuing');
|
|
117
|
+
// Don't propagate ORB errors as they don't break functionality
|
|
118
|
+
return false; // Continue
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.props.onError) {
|
|
122
|
+
this.props.onError(error, this.remoteConfig);
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
handleAnalytics = (event, data) => {
|
|
128
|
+
config.DEBUG_MODE && console.log('Onboarding analytics AdaptyOnboarding:', event, data);
|
|
129
|
+
|
|
130
|
+
if (this.props.onAnalytics) {
|
|
131
|
+
this.props.onAnalytics(event, data, this.remoteConfig);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
handlePaywall = (actionId, meta) => {
|
|
136
|
+
config.DEBUG_MODE && console.log('Onboarding paywall AdaptyOnboarding:', actionId, meta);
|
|
137
|
+
|
|
138
|
+
if (this.props.onPaywall) {
|
|
139
|
+
this.props.onPaywall(actionId, meta, this.remoteConfig);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handleFinishedLoading = (meta) => {
|
|
144
|
+
config.DEBUG_MODE && console.log('Onboarding finished loading AdaptyOnboarding:', meta);
|
|
145
|
+
|
|
146
|
+
if (this.props.onFinishedLoading) {
|
|
147
|
+
this.props.onFinishedLoading(meta, this.remoteConfig);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
151
|
+
|
|
152
|
+
render() {
|
|
153
|
+
const { visible } = this.props;
|
|
154
|
+
const { onboarding, isLoading } = this.state;
|
|
155
|
+
|
|
156
|
+
if (!visible) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const content = (
|
|
161
|
+
<View style={styles.container}>
|
|
162
|
+
{!isLoading && onboarding ? (
|
|
163
|
+
<AdaptyOnboardingView
|
|
164
|
+
onboarding={onboarding}
|
|
165
|
+
style={styles.onboardingView}
|
|
166
|
+
eventHandlers={{
|
|
167
|
+
onAnalytics: this.handleAnalytics,
|
|
168
|
+
onClose: this.handleClose,
|
|
169
|
+
onCustom: this.handleCustom,
|
|
170
|
+
onPaywall: this.handlePaywall,
|
|
171
|
+
onStateUpdated: this.handleStateUpdated,
|
|
172
|
+
onFinishedLoading: this.handleFinishedLoading,
|
|
173
|
+
onError: this.handleError,
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
) : null}
|
|
177
|
+
</View>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<Modal
|
|
182
|
+
visible={visible}
|
|
183
|
+
animationType="slide"
|
|
184
|
+
presentationStyle="fullScreen"
|
|
185
|
+
onRequestClose={() => {
|
|
186
|
+
config.DEBUG_MODE && console.log('Modal onRequestClose prevented');
|
|
187
|
+
return false;
|
|
188
|
+
}}
|
|
189
|
+
onDismiss={this.handleModalDismiss}
|
|
190
|
+
>
|
|
191
|
+
{content}
|
|
192
|
+
</Modal>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const styles = {
|
|
198
|
+
container: {
|
|
199
|
+
backgroundColor: '#000',
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
},
|
|
203
|
+
onboardingView: {
|
|
204
|
+
flex: 1,
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export default AdaptyOnboarding;
|
package/src/libraries/Adapty.js
CHANGED
|
@@ -59,6 +59,11 @@ class Adapty {
|
|
|
59
59
|
config.DEBUG_MODE && console.log('Getting paywall for placement:', placementID, 'and language:', lang, 'paywall:', paywall);
|
|
60
60
|
if (paywall) {
|
|
61
61
|
const paywallView = await this.createPaywallView(paywall);
|
|
62
|
+
|
|
63
|
+
if (!paywallView) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
62
67
|
paywallView.registerEventHandlers({
|
|
63
68
|
onCloseButtonPress: eventHandlers.onCloseButtonPress || (() => { return true; }),
|
|
64
69
|
onAndroidSystemBack: eventHandlers.onAndroidSystemBack || (() => { paywallView.dismiss(); return true; }),
|
|
@@ -104,9 +109,11 @@ class Adapty {
|
|
|
104
109
|
}
|
|
105
110
|
} else {
|
|
106
111
|
console.warn('Error preloading paywall: paywall not found for placement', placementID, 'and language', lang);
|
|
112
|
+
return null;
|
|
107
113
|
}
|
|
108
114
|
} catch (error) {
|
|
109
115
|
console.error('Error preloading paywall:', error);
|
|
116
|
+
return null;
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
|
package/types/index.d.ts
CHANGED
|
@@ -213,15 +213,34 @@ declare module 'apps-sdk' {
|
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
type OnboardingEventHandlers = {
|
|
216
|
-
onAnalytics?: (event: any, meta: any) => void;
|
|
217
|
-
onClose?: (actionId: string, meta: any) => Promise<boolean> | boolean;
|
|
218
|
-
onCustom?: (actionId: string, meta: any) => void;
|
|
219
|
-
onPaywall?: (actionId: string, meta: any) => void;
|
|
220
|
-
onStateUpdated?: (action: any, meta: any) => void;
|
|
221
|
-
onFinishedLoading?: (meta: any) => void;
|
|
222
|
-
onError?: (error: any) => void;
|
|
216
|
+
onAnalytics?: (event: any, meta: any, remoteConfig?: any) => void;
|
|
217
|
+
onClose?: (actionId: string, meta: any, remoteConfig?: any) => Promise<boolean> | boolean;
|
|
218
|
+
onCustom?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
219
|
+
onPaywall?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
220
|
+
onStateUpdated?: (action: any, meta: any, remoteConfig?: any) => void;
|
|
221
|
+
onFinishedLoading?: (meta: any, remoteConfig?: any) => void;
|
|
222
|
+
onError?: (error: any, remoteConfig?: any) => void;
|
|
223
|
+
onRemoteConfigLoaded?: (remoteConfig: any) => void;
|
|
224
|
+
onModalDismissed?: () => void;
|
|
223
225
|
};
|
|
224
226
|
|
|
227
|
+
export interface AdaptyOnboardingProps {
|
|
228
|
+
visible: boolean;
|
|
229
|
+
placementID: string;
|
|
230
|
+
lang: string;
|
|
231
|
+
onAnalytics?: (event: any, meta: any, remoteConfig?: any) => void;
|
|
232
|
+
onClose?: (actionId: string, meta: any, remoteConfig?: any) => Promise<boolean> | boolean;
|
|
233
|
+
onCustom?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
234
|
+
onPaywall?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
235
|
+
onStateUpdated?: (action: any, meta: any, remoteConfig?: any) => void;
|
|
236
|
+
onFinishedLoading?: (meta: any, remoteConfig?: any) => void;
|
|
237
|
+
onError?: (error: any, remoteConfig?: any) => boolean | void;
|
|
238
|
+
onRemoteConfigLoaded?: (remoteConfig: any) => void;
|
|
239
|
+
onModalDismissed?: () => void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export class AdaptyOnboarding extends Component<AdaptyOnboardingProps, {}> { }
|
|
243
|
+
|
|
225
244
|
export class Adapty {
|
|
226
245
|
initialize(apiKey: string): Promise<void>;
|
|
227
246
|
getPaywallForPlacement(placementID: string, lang: string): Promise<any>;
|
|
@@ -284,6 +303,7 @@ declare module 'apps-sdk' {
|
|
|
284
303
|
session : Session;
|
|
285
304
|
utils : Utils;
|
|
286
305
|
paywall : PayWall;
|
|
306
|
+
adaptyOnboarding : typeof AdaptyOnboarding;
|
|
287
307
|
rating : Rating;
|
|
288
308
|
adjust : AdJust;
|
|
289
309
|
mixpanel : MixPanel;
|