@upeex/ads-sdk 1.1.17 → 1.1.19

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.
Files changed (3) hide show
  1. package/README.md +57 -10
  2. package/dist/index.js +31 -9
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -1,16 +1,63 @@
1
1
  # SDK-apps-React-native
2
- SDK para aplicaçõe React Native rodarem anúncios:
2
+ SDK oficial da Upeex para exibir anúncios em aplicativos React Native e Expo.
3
3
 
4
- # Comando para inciar
5
- npm i @upeex/ads-sdk
4
+ ## Instalação
6
5
 
7
- ### Como importar
6
+ Instale o pacote e suas dependências via npm:
8
7
 
9
- ```js
8
+ ```bash
9
+ npm install @upeex/ads-sdk
10
+ ```
11
+
12
+ ## Como Usar
13
+
14
+ ### Importação
15
+
16
+ ```javascript
10
17
  import AdBanner from '@upeex/ads-sdk';
18
+ ```
19
+
20
+ ### 1. Banner Simples (Padrão)
21
+
22
+ Ideal para exibir em listas ou rodapés. O anúncio carrega no tamanho especificado ou padrão.
23
+
24
+ ```javascript
25
+ <AdBanner
26
+ client="SEU_ID_CLIENTE"
27
+ slot="SEU_ID_SLOT"
28
+ />
29
+ ```
30
+
31
+ ### 2. Anúncio Popup (Modal)
32
+
33
+ Exibe um anúncio em tela cheia (modal) sobrepondo o conteúdo.
34
+ **Comportamento:**
35
+ - Abre automaticamente se houver anúncio disponível.
36
+ - **Bloqueio de 5 segundos:** O usuário deve aguardar 5 segundos antes de fechar.
37
+ - **Spinner:** Um indicador de carregamento aparece durante o bloqueio.
38
+ - **Sem Auto-Refresh:** O popup carrega apenas uma vez.
39
+
40
+ ```javascript
41
+ <AdBanner
42
+ client="SEU_ID_CLIENTE"
43
+ slot="SEU_ID_SLOT"
44
+ typeads="popup"
45
+ />
46
+ ```
47
+
48
+ ### Props Disponíveis
49
+
50
+ | Prop | Tipo | Descrição |
51
+ |Data | --- | --- |
52
+ | `client` | `string` | **Obrigatório**. ID do cliente fornecido pela Upeex. |
53
+ | `slot` | `string` | **Obrigatório**. ID do slot (espaço) do anúncio. |
54
+ | `typeads` | `'banner' \| 'popup'` | Define o formato. Padrão é `'banner'`. |
55
+ | `theme` | `'light' \| 'dark'` | Define o tema (cores de fundo). Padrão `'light'`. |
56
+ | `baseUrl` | `string` | URL base da API (opcional). |
57
+ | `debug` | `boolean` | Ativa logs no console para depuração. Padrão `false`. |
58
+
59
+ ## Solução de Problemas
11
60
 
12
- // Carregar anúncio
13
- <AdBanner
14
- client="SEU_CLIENTE"
15
- slot="SEU_SLOT"
16
- /
61
+ - **Erro "Cannot find module 'react-native'"**: Certifique-se de que `react` e `react-native` estão instalados no seu projeto.
62
+ - **Popup não abre**: Verifique se `typeads="popup"` foi passado e se o console mostra logs de "Nenhum anúncio disponível" (use `debug={true}`).
63
+ - **Sobreposição**: O popup possui `zIndex: 9999` e `elevation: 11`. Se ainda estiver atrás de algum elemento, verifique se o componente pai não tem um `zIndex` maior ou se está dentro de um Modal nativo do OS.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
- import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableOpacity, Image, Linking } from 'react-native';
3
+ import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableWithoutFeedback, TouchableOpacity, ActivityIndicator, Image, Linking } from 'react-native';
4
4
 
5
5
  async function getSignals() {
6
6
  var _a, _b, _c, _d, _e, _f;
@@ -114,7 +114,8 @@ style = {}, debug = false, }) {
114
114
  if (isPopup) {
115
115
  setModalVisible(true);
116
116
  }
117
- if (data.refresh && data.refresh > 0) {
117
+ // Only setup refresh if NOT a popup
118
+ if (!isPopup && data.refresh && data.refresh > 0) {
118
119
  log(`Refresh ativo: ${data.refresh}s`);
119
120
  refreshTimer = setTimeout(() => {
120
121
  log('Refazendo request do anúncio');
@@ -136,9 +137,22 @@ style = {}, debug = false, }) {
136
137
  clearTimeout(refreshTimer);
137
138
  };
138
139
  }, [client, slot, baseUrl, effectiveTypeAds]);
140
+ // Popup close delay logic
141
+ const [canClose, setCanClose] = useState(false);
142
+ useEffect(() => {
143
+ if (isPopup && modalVisible) {
144
+ setCanClose(false);
145
+ const timer = setTimeout(() => {
146
+ setCanClose(true);
147
+ }, 5000);
148
+ return () => clearTimeout(timer);
149
+ }
150
+ }, [isPopup, modalVisible]);
139
151
  const handlePress = () => {
140
152
  log('Clique no anúncio', ad.clickUrl);
141
153
  if (isPopup) {
154
+ // Allow close on click even if timer not finished?
155
+ // Usually ads allow clicking through immediately.
142
156
  setModalVisible(false);
143
157
  }
144
158
  if (!ad.clickUrl)
@@ -151,7 +165,9 @@ style = {}, debug = false, }) {
151
165
  }
152
166
  };
153
167
  const handleClose = () => {
154
- setModalVisible(false);
168
+ if (canClose) {
169
+ setModalVisible(false);
170
+ }
155
171
  };
156
172
  if (error) {
157
173
  return debug ? (jsx(View, { style: [styles.upeexContainer, styles.upeexDebug], children: jsx(Text, { style: styles.upeexDebugText, children: error }) })) : null;
@@ -160,11 +176,14 @@ style = {}, debug = false, }) {
160
176
  return debug ? (jsx(View, { style: [styles.upeexContainer, styles.upeexLoading], children: jsx(Text, { style: styles.upeexLoadingText, children: "Carregando an\u00FAncio\u2026" }) })) : null;
161
177
  }
162
178
  if (isPopup) {
163
- return (jsx(Modal, { transparent: true, visible: modalVisible, onRequestClose: handleClose, animationType: "fade", children: jsx(View, { style: styles.upeexOverlay, children: jsxs(View, { style: [styles.upeexPopupContainer, theme === 'dark' && styles.upeexDark], children: [jsx(TouchableOpacity, { onPress: handleClose, style: styles.upeexCloseButton, children: jsx(Text, { style: styles.upeexCloseText, children: "\u2715" }) }), jsx(TouchableOpacity, { activeOpacity: 0.9, onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
164
- width: ad.width || 300,
165
- height: ad.height || 300,
166
- resizeMode: 'contain',
167
- } }) })] }) }) }));
179
+ return (jsx(Modal, { transparent: true, visible: modalVisible, onRequestClose: handleClose, animationType: "fade", children: jsx(TouchableWithoutFeedback, { onPress: handleClose, children: jsx(View, { style: styles.upeexOverlay, children: jsx(TouchableWithoutFeedback, { onPress: () => { }, children: jsxs(View, { style: [
180
+ styles.upeexPopupContainer,
181
+ theme === 'dark' && styles.upeexDark,
182
+ ], children: [canClose ? (jsx(TouchableOpacity, { onPress: handleClose, style: styles.upeexCloseButton, children: jsx(Text, { style: styles.upeexCloseText, children: "\u2715" }) })) : (jsx(View, { style: styles.upeexCloseButton, children: jsx(ActivityIndicator, { size: "small", color: "#999" }) })), jsx(TouchableOpacity, { activeOpacity: 0.9, onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
183
+ width: ad.width || 300,
184
+ height: ad.height || 300,
185
+ resizeMode: 'contain',
186
+ } }) })] }) }) }) }) }));
168
187
  }
169
188
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
170
189
  styles.upeexContainer,
@@ -205,6 +224,8 @@ const styles = StyleSheet.create({
205
224
  backgroundColor: 'rgba(0, 0, 0, 0.5)',
206
225
  justifyContent: 'center',
207
226
  alignItems: 'center',
227
+ zIndex: 9999,
228
+ elevation: 10,
208
229
  },
209
230
  upeexPopupContainer: {
210
231
  backgroundColor: '#fff',
@@ -212,11 +233,12 @@ const styles = StyleSheet.create({
212
233
  borderRadius: 10,
213
234
  alignItems: 'center',
214
235
  position: 'relative',
215
- elevation: 5,
236
+ elevation: 11,
216
237
  shadowColor: '#000',
217
238
  shadowOffset: { width: 0, height: 2 },
218
239
  shadowOpacity: 0.25,
219
240
  shadowRadius: 3.84,
241
+ zIndex: 10000,
220
242
  },
221
243
  upeexCloseButton: {
222
244
  position: 'absolute',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upeex/ads-sdk",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "Upeex Ads SDK for React Native and universal apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,6 +34,8 @@
34
34
  "rollup": "^4.57.0",
35
35
  "rollup-plugin-typescript2": "^0.36.0",
36
36
  "tslib": "^2.8.1",
37
- "typescript": "^5.9.3"
37
+ "typescript": "^5.9.3",
38
+ "react": "18.2.0",
39
+ "react-native": "0.73.0"
38
40
  }
39
41
  }