apps-sdk 1.1.54 → 1.1.56
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 +150 -0
- package/src/libraries/Facebook.js +5 -0
- package/types/index.d.ts +17 -0
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} 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,150 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Adapty from '../libraries/Adapty';
|
|
3
|
+
import * as config from '../../config';
|
|
4
|
+
|
|
5
|
+
class AdaptyOnboarding extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.onboardingView = null;
|
|
9
|
+
this.isPresenting = false;
|
|
10
|
+
this.remoteConfig = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async componentDidMount() {
|
|
14
|
+
if (this.props.visible) {
|
|
15
|
+
await this.presentOnboarding();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async componentDidUpdate(prevProps) {
|
|
20
|
+
if (this.props.visible && !prevProps.visible && !this.isPresenting) {
|
|
21
|
+
await this.presentOnboarding();
|
|
22
|
+
} else if (!this.props.visible && prevProps.visible) {
|
|
23
|
+
await this.dismissOnboarding();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
componentWillUnmount() {
|
|
28
|
+
this.dismissOnboarding();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
presentOnboarding = async () => {
|
|
32
|
+
const {
|
|
33
|
+
placementID,
|
|
34
|
+
lang,
|
|
35
|
+
onCustom,
|
|
36
|
+
onClose,
|
|
37
|
+
onError,
|
|
38
|
+
onRemoteConfigLoaded,
|
|
39
|
+
...handlers
|
|
40
|
+
} = this.props;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
this.isPresenting = true;
|
|
44
|
+
const onboarding = await Adapty.getOnboardingForPlacement(placementID, lang);
|
|
45
|
+
|
|
46
|
+
if (onboarding) {
|
|
47
|
+
// Extraer y guardar remote config
|
|
48
|
+
this.remoteConfig = onboarding.remoteConfig || {};
|
|
49
|
+
|
|
50
|
+
// Callback inicial con el config
|
|
51
|
+
if (onRemoteConfigLoaded && this.remoteConfig) {
|
|
52
|
+
config.DEBUG_MODE && console.log('Remote config loaded:', this.remoteConfig);
|
|
53
|
+
onRemoteConfigLoaded(this.remoteConfig);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.onboardingView = await Adapty.createOnboardingView(onboarding);
|
|
57
|
+
|
|
58
|
+
this.onboardingView.registerEventHandlers({
|
|
59
|
+
onCustom: (actionId, meta) => {
|
|
60
|
+
config.DEBUG_MODE && console.log('Onboarding custom action:', actionId, meta);
|
|
61
|
+
// Pasar remoteConfig en el handler
|
|
62
|
+
if (onCustom) {
|
|
63
|
+
onCustom(actionId, meta, this.remoteConfig);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
onClose: async (actionId, meta) => {
|
|
67
|
+
config.DEBUG_MODE && console.log('Onboarding closed:', actionId, meta);
|
|
68
|
+
this.isPresenting = false;
|
|
69
|
+
// Pasar remoteConfig en el handler
|
|
70
|
+
if (onClose) {
|
|
71
|
+
onClose(actionId, meta, this.remoteConfig);
|
|
72
|
+
}
|
|
73
|
+
await this.onboardingView.dismiss();
|
|
74
|
+
return true;
|
|
75
|
+
},
|
|
76
|
+
onError: (error) => {
|
|
77
|
+
console.error('Onboarding error:', error);
|
|
78
|
+
this.isPresenting = false;
|
|
79
|
+
// Pasar remoteConfig en el handler
|
|
80
|
+
if (onError) {
|
|
81
|
+
onError(error, this.remoteConfig);
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
},
|
|
85
|
+
onAnalytics: (event, data) => {
|
|
86
|
+
config.DEBUG_MODE && console.log('Onboarding analytics:', event, data);
|
|
87
|
+
if (handlers.onAnalytics) {
|
|
88
|
+
handlers.onAnalytics(event, data, this.remoteConfig);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
onPaywall: () => {
|
|
92
|
+
config.DEBUG_MODE && console.log('Onboarding paywall event');
|
|
93
|
+
if (handlers.onPaywall) {
|
|
94
|
+
handlers.onPaywall(this.remoteConfig);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onStateUpdated: (state) => {
|
|
98
|
+
config.DEBUG_MODE && console.log('Onboarding state updated:', state);
|
|
99
|
+
if (handlers.onStateUpdated) {
|
|
100
|
+
handlers.onStateUpdated(state, this.remoteConfig);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onFinishedLoading: () => {
|
|
104
|
+
config.DEBUG_MODE && console.log('Onboarding finished loading');
|
|
105
|
+
if (handlers.onFinishedLoading) {
|
|
106
|
+
handlers.onFinishedLoading(this.remoteConfig);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
await this.onboardingView.present();
|
|
112
|
+
} else {
|
|
113
|
+
console.warn('Onboarding not found for placement:', placementID, 'and language:', lang);
|
|
114
|
+
if (this.props.onError) {
|
|
115
|
+
this.props.onError(new Error('Onboarding not found'), this.remoteConfig);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('Error presenting onboarding:', error);
|
|
120
|
+
this.isPresenting = false;
|
|
121
|
+
if (this.props.onError) {
|
|
122
|
+
this.props.onError(error, this.remoteConfig);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
dismissOnboarding = async () => {
|
|
128
|
+
if (this.onboardingView && this.isPresenting) {
|
|
129
|
+
try {
|
|
130
|
+
await this.onboardingView.dismiss();
|
|
131
|
+
this.isPresenting = false;
|
|
132
|
+
this.remoteConfig = null;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('Error dismissing onboarding:', error);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Método público para acceder al config desde el componente padre (opcional)
|
|
140
|
+
getRemoteConfig = () => {
|
|
141
|
+
return this.remoteConfig;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
render() {
|
|
145
|
+
// Componente invisible, el onboarding se presenta nativamente
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default AdaptyOnboarding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppEventsLogger, Settings } from 'react-native-fbsdk-next';
|
|
2
2
|
import * as config from '../../config';
|
|
3
3
|
import Networking from "./Networking";
|
|
4
|
+
import TrackingTransparency from './TrackingTransparency';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* "react-native-fbsdk-next" events coding:
|
|
@@ -43,6 +44,10 @@ class Facebook {
|
|
|
43
44
|
// Settings.setAutoInitEnabled(true);
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
const trackingStatus = await TrackingTransparency.getTrackingTransparencyPermission();
|
|
48
|
+
await Settings.setAdvertiserTrackingEnabled(trackingStatus === 'granted');
|
|
49
|
+
config.DEBUG_MODE && console.log('Facebook Tracking Transparency status:', trackingStatus);
|
|
50
|
+
|
|
46
51
|
await Settings.initializeSDK();
|
|
47
52
|
|
|
48
53
|
this.isInitialized = true;
|
package/types/index.d.ts
CHANGED
|
@@ -158,6 +158,22 @@ declare module 'apps-sdk' {
|
|
|
158
158
|
|
|
159
159
|
export class PayWall extends Component<PayWallProps, {}> {}
|
|
160
160
|
|
|
161
|
+
export interface AdaptyOnboardingProps {
|
|
162
|
+
visible: boolean;
|
|
163
|
+
placementID: string;
|
|
164
|
+
lang: string;
|
|
165
|
+
onCustom?: (actionId: string, meta?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
166
|
+
onClose?: (actionId: string, meta?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
167
|
+
onError?: (error: Error | string | any, remoteConfig?: Record<string, any>) => void;
|
|
168
|
+
onRemoteConfigLoaded?: (remoteConfig: Record<string, any>) => void;
|
|
169
|
+
onAnalytics?: (event: string | any, data?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
170
|
+
onPaywall?: (remoteConfig?: Record<string, any>) => void;
|
|
171
|
+
onStateUpdated?: (state: any, remoteConfig?: Record<string, any>) => void;
|
|
172
|
+
onFinishedLoading?: (remoteConfig?: Record<string, any>) => void;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class AdaptyOnboarding extends Component<AdaptyOnboardingProps, {}> {}
|
|
176
|
+
|
|
161
177
|
export class PayWallLogic {
|
|
162
178
|
initializePayWall(): Promise<void>;
|
|
163
179
|
executePurchase(productID: string): Promise<void>;
|
|
@@ -278,6 +294,7 @@ declare module 'apps-sdk' {
|
|
|
278
294
|
session : Session;
|
|
279
295
|
utils : Utils;
|
|
280
296
|
paywall : PayWall;
|
|
297
|
+
adaptyOnboarding : typeof AdaptyOnboarding;
|
|
281
298
|
rating : Rating;
|
|
282
299
|
adjust : AdJust;
|
|
283
300
|
mixpanel : MixPanel;
|