apps-sdk 1.1.66 → 1.1.68

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 CHANGED
@@ -1,6 +1,5 @@
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";
4
3
 
5
4
  class AppsSDK {
6
5
  constructor() {
@@ -57,7 +56,6 @@ export default {
57
56
  mixpanel: MixPanel,
58
57
  tracking: TrackingTransparency,
59
58
  paywall: PayWall,
60
- adaptyOnboarding: AdaptyOnboarding,
61
59
  notifications: NotificationsPush,
62
60
  voice: Voice,
63
61
  adapty: Adapty,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.1.66",
3
+ "version": "1.1.68",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -59,11 +59,6 @@ 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
-
67
62
  paywallView.registerEventHandlers({
68
63
  onCloseButtonPress: eventHandlers.onCloseButtonPress || (() => { return true; }),
69
64
  onAndroidSystemBack: eventHandlers.onAndroidSystemBack || (() => { paywallView.dismiss(); return true; }),
@@ -109,11 +104,9 @@ class Adapty {
109
104
  }
110
105
  } else {
111
106
  console.warn('Error preloading paywall: paywall not found for placement', placementID, 'and language', lang);
112
- return null;
113
107
  }
114
108
  } catch (error) {
115
109
  console.error('Error preloading paywall:', error);
116
- return null;
117
110
  }
118
111
  }
119
112
 
@@ -146,6 +146,70 @@ class Facebook {
146
146
  getApplicationId() {
147
147
  return this.appId;
148
148
  }
149
+
150
+ async getCampaignData() {
151
+ if (!this.isInitialized) {
152
+ console.log('Facebook is not initialized');
153
+ return null;
154
+ }
155
+
156
+ try {
157
+ // Import AppLink from react-native-fbsdk-next
158
+ const { AppLink } = await import('react-native-fbsdk-next');
159
+
160
+ config.DEBUG_MODE && console.log('Fetching deferred app link data from Meta...');
161
+
162
+ // Fetch deferred app link - this returns the URL or null
163
+ const deferredAppLink = await AppLink.fetchDeferredAppLink();
164
+
165
+ if (deferredAppLink) {
166
+ config.DEBUG_MODE && console.log('Deferred app link received:', deferredAppLink);
167
+
168
+ // Parse the URL to extract campaign parameters
169
+ const campaignData = this.parseCampaignUrl(deferredAppLink);
170
+
171
+ config.DEBUG_MODE && console.log('Parsed campaign data:', campaignData);
172
+
173
+ return {
174
+ url: deferredAppLink,
175
+ ...campaignData
176
+ };
177
+ } else {
178
+ config.DEBUG_MODE && console.log('No deferred app link data available');
179
+ return null;
180
+ }
181
+ } catch (error) {
182
+ console.error('Error fetching campaign data from Meta:', error);
183
+ Networking.sendEvent('other', 'facebook_campaign_data_error', { error: error.message });
184
+ return null;
185
+ }
186
+ }
187
+
188
+
189
+ parseCampaignUrl(url) {
190
+ try {
191
+ const urlObj = new URL(url);
192
+ const params = {};
193
+
194
+ // Extract all query parameters
195
+ urlObj.searchParams.forEach((value, key) => {
196
+ params[key] = value;
197
+ });
198
+
199
+ return {
200
+ params,
201
+ host: urlObj.host,
202
+ path: urlObj.pathname,
203
+ protocol: urlObj.protocol
204
+ };
205
+ } catch (error) {
206
+ console.error('Error parsing campaign URL:', error);
207
+ return {
208
+ params: {},
209
+ raw_url: url
210
+ };
211
+ }
212
+ }
149
213
  }
150
214
 
151
- export default new Facebook();
215
+ export default new Facebook();
@@ -75,9 +75,15 @@ class VoiceService {
75
75
  'eng': 'en_US',
76
76
  'spa': 'es_ES',
77
77
  'fra': 'fr_FR',
78
- 'ita': 'it_IT',
79
78
  'por': 'pt_PT',
80
79
  'deu': 'de_DE',
80
+ 'fin': 'fi_FI',
81
+ 'nld': 'nl_NL',
82
+ 'tur': 'tr_TR',
83
+ 'ron': 'ro_RO',
84
+ 'arb': 'ar_SA',
85
+ 'jpn': 'ja_JP',
86
+ 'nor': 'no_NO',
81
87
  };
82
88
 
83
89
  const detectedLanguage = languageMap[detectedLanguageCode] || 'en_US';
package/types/index.d.ts CHANGED
@@ -213,34 +213,15 @@ declare module 'apps-sdk' {
213
213
  };
214
214
 
215
215
  type OnboardingEventHandlers = {
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;
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;
225
223
  };
226
224
 
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
-
244
225
  export class Adapty {
245
226
  initialize(apiKey: string): Promise<void>;
246
227
  getPaywallForPlacement(placementID: string, lang: string): Promise<any>;
@@ -303,7 +284,6 @@ declare module 'apps-sdk' {
303
284
  session : Session;
304
285
  utils : Utils;
305
286
  paywall : PayWall;
306
- adaptyOnboarding : typeof AdaptyOnboarding;
307
287
  rating : Rating;
308
288
  adjust : AdJust;
309
289
  mixpanel : MixPanel;
@@ -1,208 +0,0 @@
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;