@thealteroffice/react-native-adgeist 0.0.4 → 0.0.6
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/Adgeist.podspec +1 -1
- package/README.md +249 -40
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/adgeist/implementation/AdgeistModuleImpl.kt +53 -39
- package/ios/Adgeist.mm +26 -9
- package/ios/AdgeistImpl.swift +19 -2
- package/lib/module/components/BannerAd.js +19 -1
- package/lib/module/components/BannerAd.js.map +1 -1
- package/lib/typescript/src/components/BannerAd.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/BannerAd.tsx +18 -0
package/Adgeist.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
|
|
19
|
-
s.dependency "AdgeistKit", '= 0.0.
|
|
19
|
+
s.dependency "AdgeistKit", '= 0.0.3'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/README.md
CHANGED
|
@@ -4,72 +4,281 @@
|
|
|
4
4
|
|
|
5
5
|
# @thealteroffice/react-native-adgeist
|
|
6
6
|
|
|
7
|
-
A React Native
|
|
8
|
-
Written in Kotlin, Swift and Typescript. It supports both the Old and New React Native architecture.
|
|
7
|
+
A React Native SDK that enables publishers to seamlessly integrate their ad spaces with the AdGeist marketplace. Built with TypeScript, Kotlin, and Swift, supporting both Old and New React Native architectures with TurboModule support.
|
|
9
8
|
|
|
10
|
-
##
|
|
9
|
+
## 🚀 Features
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
- ✅ **Cross-platform**: iOS and Android support
|
|
12
|
+
- ✅ **Modern Architecture**: Support for both legacy and new React Native architectures
|
|
13
|
+
- ✅ **TurboModule**: Enhanced performance with TurboModule implementation
|
|
14
|
+
- ✅ **TypeScript**: Full TypeScript support with type definitions
|
|
15
|
+
- ✅ **Expo Compatible**: Config plugin for seamless Expo integration
|
|
16
|
+
- ✅ **Analytics**: Built-in impression and click tracking
|
|
17
|
+
- ✅ **Customizable**: Flexible ad display options
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
## 📦 Installation
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
npm install @thealteroffice/react-native-adgeist
|
|
18
|
-
```
|
|
21
|
+
### React Native CLI
|
|
19
22
|
|
|
20
|
-
```
|
|
23
|
+
```bash
|
|
24
|
+
npm install @thealteroffice/react-native-adgeist
|
|
25
|
+
# or
|
|
21
26
|
yarn add @thealteroffice/react-native-adgeist
|
|
22
27
|
```
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
For iOS, run pod install:
|
|
30
|
+
```bash
|
|
31
|
+
cd ios && pod install
|
|
32
|
+
```
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
### Expo Managed Workflow
|
|
29
35
|
|
|
30
|
-
```
|
|
36
|
+
```bash
|
|
31
37
|
npx expo install @thealteroffice/react-native-adgeist
|
|
32
38
|
```
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
Rebuild your app:
|
|
41
|
+
```bash
|
|
42
|
+
npx expo prebuild --clean
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> **Note**: Requires Expo SDK 50+ and Kotlin template support.
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
## 🔧 Setup & Configuration
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
### Basic Setup
|
|
39
50
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
Wrap your app with `AdgeistProvider` to configure global settings:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import React from 'react';
|
|
55
|
+
import { AdgeistProvider, BannerAd } from '@thealteroffice/react-native-adgeist';
|
|
56
|
+
|
|
57
|
+
export default function App() {
|
|
58
|
+
return (
|
|
59
|
+
<AdgeistProvider
|
|
60
|
+
publisherId="your-publisher-id"
|
|
61
|
+
apiKey="your-api-key"
|
|
62
|
+
domain="your-domain"
|
|
63
|
+
isTestEnvironment="your-environment"
|
|
64
|
+
>
|
|
65
|
+
<YourAppContent />
|
|
66
|
+
</AdgeistProvider>
|
|
67
|
+
);
|
|
45
68
|
}
|
|
46
69
|
```
|
|
47
70
|
|
|
48
|
-
|
|
71
|
+
### Environment Configuration
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
73
|
+
Set `isTestEnvironment` based on your app's environment:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
const isTestMode = __DEV__ || process.env.NODE_ENV === 'development';
|
|
77
|
+
|
|
78
|
+
<AdgeistProvider
|
|
79
|
+
publisherId="your-publisher-id"
|
|
80
|
+
apiKey="your-api-key"
|
|
81
|
+
domain="your-domain"
|
|
82
|
+
isTestEnvironment={isTestMode}
|
|
83
|
+
>
|
|
52
84
|
```
|
|
53
85
|
|
|
54
|
-
|
|
86
|
+
## 📱 Components
|
|
87
|
+
|
|
88
|
+
### AdgeistProvider
|
|
89
|
+
|
|
90
|
+
The root provider component that configures the SDK globally.
|
|
91
|
+
|
|
92
|
+
#### Props
|
|
55
93
|
|
|
56
|
-
|
|
94
|
+
| Prop | Type | Required | Default | Description |
|
|
95
|
+
|------|------|----------|---------|-------------|
|
|
96
|
+
| `children` | `React.ReactNode` | ✅ | - | Child components |
|
|
97
|
+
| `publisherId` | `string` | ✅ | - | Your publisher ID from AdGeist dashboard |
|
|
98
|
+
| `apiKey` | `string` | ✅ | - | Your API key from AdGeist dashboard |
|
|
99
|
+
| `domain` | `string` | ✅ | - | Your registered domain (e.g., "https://adgeist.ai") |
|
|
100
|
+
| `isTestEnvironment` | `boolean` | ✅ | - | Enable test mode for development |
|
|
57
101
|
|
|
58
|
-
|
|
102
|
+
#### Example
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<AdgeistProvider
|
|
106
|
+
publisherId="67f8ad1350ff1e0870da3f5b"
|
|
107
|
+
apiKey="7f6b3361bd6d804edfb40cecf3f42e5ebc0b11bd88d96c8a6d64188b93447ad9"
|
|
108
|
+
domain="https://adgeist.ai"
|
|
109
|
+
isTestEnvironment={false}
|
|
110
|
+
>
|
|
111
|
+
<App />
|
|
112
|
+
</AdgeistProvider>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### BannerAd
|
|
116
|
+
|
|
117
|
+
Display banner advertisements in your app.
|
|
118
|
+
|
|
119
|
+
#### Props
|
|
120
|
+
|
|
121
|
+
| Prop | Type | Required | Default | Description |
|
|
122
|
+
|------|------|----------|---------|-------------|
|
|
123
|
+
| `dataAdSlot` | `string` | ✅ | - | Ad slot ID from your AdGeist dashboard |
|
|
124
|
+
| `width` | `number` | ❌ | Device width | Width of the ad banner |
|
|
125
|
+
| `height` | `number` | ❌ | `300` | Height of the ad banner |
|
|
126
|
+
|
|
127
|
+
#### Example
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
59
130
|
import { BannerAd } from '@thealteroffice/react-native-adgeist';
|
|
60
|
-
import { BottomBannerAd } from '@thealteroffice/react-native-adgeist';
|
|
61
131
|
|
|
62
|
-
|
|
132
|
+
function MyScreen() {
|
|
133
|
+
return (
|
|
134
|
+
<View>
|
|
135
|
+
<BannerAd
|
|
136
|
+
dataAdSlot="686149fac1fd09fff371e53c"
|
|
137
|
+
width={350}
|
|
138
|
+
height={250}
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 🔧 Native Module API
|
|
146
|
+
|
|
147
|
+
For advanced use cases, you can directly use the native module:
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import Adgeist from '@thealteroffice/react-native-adgeist/src/NativeAdgeist';
|
|
151
|
+
|
|
152
|
+
// Fetch creative data
|
|
153
|
+
const adData = await Adgeist.fetchCreative(
|
|
154
|
+
apiKey,
|
|
155
|
+
origin,
|
|
156
|
+
adSpaceId,
|
|
157
|
+
publisherId,
|
|
158
|
+
isTestEnvironment
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// Send analytics
|
|
162
|
+
await Adgeist.sendCreativeAnalytic(
|
|
163
|
+
campaignId,
|
|
164
|
+
adSpaceId,
|
|
165
|
+
publisherId,
|
|
166
|
+
eventType, // 'IMPRESSION' | 'CLICK'
|
|
167
|
+
origin,
|
|
168
|
+
apiKey,
|
|
169
|
+
bidId,
|
|
170
|
+
isTestEnvironment
|
|
171
|
+
);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Native Module Methods
|
|
175
|
+
|
|
176
|
+
#### `fetchCreative`
|
|
177
|
+
|
|
178
|
+
Fetches ad creative data from the AdGeist API.
|
|
179
|
+
|
|
180
|
+
| Parameter | Type | Required | Description |
|
|
181
|
+
|-----------|------|----------|-------------|
|
|
182
|
+
| `apiKey` | `string` | ✅ | Your API key |
|
|
183
|
+
| `origin` | `string` | ✅ | App domain/origin |
|
|
184
|
+
| `adSpaceId` | `string` | ✅ | Ad space identifier |
|
|
185
|
+
| `publisherId` | `string` | ✅ | Publisher identifier |
|
|
186
|
+
| `isTestEnvironment` | `boolean` | ✅ | Test mode flag |
|
|
187
|
+
|
|
188
|
+
**Returns**: `Promise<AdData>`
|
|
189
|
+
|
|
190
|
+
#### `sendCreativeAnalytic`
|
|
191
|
+
|
|
192
|
+
Sends analytics data for ad interactions.
|
|
193
|
+
|
|
194
|
+
| Parameter | Type | Required | Description |
|
|
195
|
+
|-----------|------|----------|-------------|
|
|
196
|
+
| `campaignId` | `string` | ✅ | Campaign identifier |
|
|
197
|
+
| `adSpaceId` | `string` | ✅ | Ad space identifier |
|
|
198
|
+
| `publisherId` | `string` | ✅ | Publisher identifier |
|
|
199
|
+
| `eventType` | `string` | ✅ | Event type ('IMPRESSION' or 'CLICK') |
|
|
200
|
+
| `origin` | `string` | ✅ | App domain/origin |
|
|
201
|
+
| `apiKey` | `string` | ✅ | Your API key |
|
|
202
|
+
| `bidId` | `string` | ✅ | Bid identifier |
|
|
203
|
+
| `isTestEnvironment` | `boolean` | ✅ | Test mode flag |
|
|
204
|
+
|
|
205
|
+
**Returns**: `Promise<Object>`
|
|
206
|
+
|
|
207
|
+
## 📊 Data Types
|
|
208
|
+
|
|
209
|
+
### AdData Interface
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
interface AdData {
|
|
213
|
+
id: string;
|
|
214
|
+
bidId: string;
|
|
215
|
+
cur: string;
|
|
216
|
+
seatBid: SeatBid[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface SeatBid {
|
|
220
|
+
bidId: string;
|
|
221
|
+
bid: Bid[];
|
|
222
|
+
}
|
|
63
223
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
224
|
+
interface Bid {
|
|
225
|
+
id: string;
|
|
226
|
+
impId: string;
|
|
227
|
+
price: number;
|
|
228
|
+
ext: BidExtension;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface BidExtension {
|
|
232
|
+
creativeUrl: string;
|
|
233
|
+
ctaUrl: string;
|
|
234
|
+
creativeTitle: string;
|
|
235
|
+
creativeDescription: string;
|
|
236
|
+
creativeBrandName?: string;
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 🎨 Customization
|
|
241
|
+
|
|
242
|
+
### Custom Ad Loader
|
|
243
|
+
|
|
244
|
+
Create your own ad loading component:
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import React, { useState, useEffect } from 'react';
|
|
248
|
+
import { useAdgeistContext } from '@thealteroffice/react-native-adgeist';
|
|
249
|
+
import Adgeist from '@thealteroffice/react-native-adgeist/src/NativeAdgeist';
|
|
250
|
+
|
|
251
|
+
function CustomAdLoader({ adSlotId }) {
|
|
252
|
+
const [adData, setAdData] = useState(null);
|
|
253
|
+
const [loading, setLoading] = useState(true);
|
|
254
|
+
const { publisherId, apiKey, domain, isTestEnvironment } = useAdgeistContext();
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
loadAd();
|
|
258
|
+
}, []);
|
|
259
|
+
|
|
260
|
+
const loadAd = async () => {
|
|
261
|
+
try {
|
|
262
|
+
const response = await Adgeist.fetchCreative(
|
|
263
|
+
apiKey,
|
|
264
|
+
domain,
|
|
265
|
+
adSlotId,
|
|
266
|
+
publisherId,
|
|
267
|
+
isTestEnvironment
|
|
268
|
+
);
|
|
269
|
+
setAdData(response.data);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.error('Failed to load ad:', error);
|
|
272
|
+
} finally {
|
|
273
|
+
setLoading(false);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
if (loading) return <LoadingSpinner />;
|
|
278
|
+
if (!adData) return null;
|
|
279
|
+
|
|
280
|
+
return <YourCustomAdDisplay data={adData} />;
|
|
281
|
+
}
|
|
282
|
+
```
|
|
70
283
|
|
|
71
|
-
<BottomBannerAd
|
|
72
|
-
dataPublisherId={PUBLISHER_ID}
|
|
73
|
-
dataAdSlot={ADSPACE_ID}
|
|
74
|
-
/>
|
|
75
284
|
```
|
package/android/build.gradle
CHANGED
|
@@ -101,7 +101,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
101
101
|
|
|
102
102
|
dependencies {
|
|
103
103
|
implementation "com.facebook.react:react-android"
|
|
104
|
-
implementation "ai.adgeist:adgeistkit:0.0.
|
|
104
|
+
implementation "ai.adgeist:adgeistkit:0.0.6"
|
|
105
105
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -46,43 +46,57 @@ class AdgeistModuleImpl internal constructor(private val context: ReactApplicati
|
|
|
46
46
|
|
|
47
47
|
// Extension function to convert CreativeDataModel to WritableMap
|
|
48
48
|
fun CreativeDataModel.toWritableMap(): WritableMap {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
49
|
+
val map = Arguments.createMap()
|
|
50
|
+
|
|
51
|
+
map.putBoolean("success", this.success)
|
|
52
|
+
map.putString("message", this.message)
|
|
53
|
+
|
|
54
|
+
// Handle null data - store in local variable for smart casting
|
|
55
|
+
val dataValue = this.data
|
|
56
|
+
if (dataValue != null) {
|
|
57
|
+
val dataMap = Arguments.createMap()
|
|
58
|
+
dataMap.putString("id", dataValue.id)
|
|
59
|
+
dataMap.putString("bidId", dataValue.bidId)
|
|
60
|
+
dataMap.putString("cur", dataValue.cur)
|
|
61
|
+
|
|
62
|
+
// Handle null seatBid list - store in local variable
|
|
63
|
+
val seatBidArray = Arguments.createArray()
|
|
64
|
+
val seatBidList = dataValue.seatBid
|
|
65
|
+
if (seatBidList != null) {
|
|
66
|
+
for (seatBid in seatBidList) {
|
|
67
|
+
val seatBidMap = Arguments.createMap()
|
|
68
|
+
seatBidMap.putString("bidId", seatBid.bidId)
|
|
69
|
+
|
|
70
|
+
// Handle null bid list - store in local variable
|
|
71
|
+
val bidArray = Arguments.createArray()
|
|
72
|
+
val bidList = seatBid.bid
|
|
73
|
+
if (bidList != null) {
|
|
74
|
+
for (bid in bidList) {
|
|
75
|
+
val bidMap = Arguments.createMap()
|
|
76
|
+
bidMap.putString("id", bid.id)
|
|
77
|
+
bidMap.putString("impId", bid.impId)
|
|
78
|
+
bidMap.putDouble("price", bid.price)
|
|
79
|
+
|
|
80
|
+
// Handle extension
|
|
81
|
+
val extMap = Arguments.createMap()
|
|
82
|
+
extMap.putString("creativeUrl", bid.ext.creativeUrl)
|
|
83
|
+
extMap.putString("ctaUrl", bid.ext.ctaUrl)
|
|
84
|
+
extMap.putString("creativeTitle", bid.ext.creativeTitle)
|
|
85
|
+
extMap.putString("creativeDescription", bid.ext.creativeDescription)
|
|
86
|
+
|
|
87
|
+
bidMap.putMap("ext", extMap)
|
|
88
|
+
bidArray.pushMap(bidMap)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
seatBidMap.putArray("bid", bidArray)
|
|
92
|
+
seatBidArray.pushMap(seatBidMap)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
dataMap.putArray("seatBid", seatBidArray)
|
|
96
|
+
map.putMap("data", dataMap)
|
|
97
|
+
} else {
|
|
98
|
+
map.putNull("data")
|
|
82
99
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
map.putMap("data", dataMap)
|
|
87
|
-
return map
|
|
88
|
-
}
|
|
100
|
+
|
|
101
|
+
return map
|
|
102
|
+
}
|
package/ios/Adgeist.mm
CHANGED
|
@@ -22,25 +22,42 @@ RCT_EXPORT_MODULE(Adgeist)
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
// Exported methods for JS
|
|
25
|
-
RCT_EXPORT_METHOD(fetchCreative:(NSString *)
|
|
25
|
+
RCT_EXPORT_METHOD(fetchCreative:(NSString *)apiKey
|
|
26
|
+
origin:(NSString *)origin
|
|
27
|
+
adSpaceId:(NSString *)adSpaceId
|
|
26
28
|
publisherId:(NSString *)publisherId
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
30
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
31
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
29
32
|
{
|
|
30
|
-
[adgeist
|
|
33
|
+
[adgeist fetchCreativeWithApiKey:apiKey
|
|
34
|
+
origin:origin
|
|
35
|
+
adSpaceId:adSpaceId
|
|
36
|
+
publisherId:publisherId
|
|
37
|
+
isTestEnvironment:isTestEnvironment
|
|
38
|
+
resolver:resolve
|
|
39
|
+
rejecter:reject];
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
RCT_EXPORT_METHOD(sendCreativeAnalytic:(NSString *)campaignId
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
adSpaceId:(NSString *)adSpaceId
|
|
44
|
+
publisherId:(NSString *)publisherId
|
|
45
|
+
eventType:(NSString *)eventType
|
|
46
|
+
origin:(NSString *)origin
|
|
47
|
+
apiKey:(NSString *)apiKey
|
|
48
|
+
bidId:(NSString *)bidId
|
|
49
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
50
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
51
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
39
52
|
{
|
|
40
53
|
[adgeist sendCreativeAnalyticWithCampaignId:campaignId
|
|
41
54
|
adSpaceId:adSpaceId
|
|
42
55
|
publisherId:publisherId
|
|
43
56
|
eventType:eventType
|
|
57
|
+
origin:origin
|
|
58
|
+
apiKey:apiKey
|
|
59
|
+
bidId:bidId
|
|
60
|
+
isTestEnvironment:isTestEnvironment
|
|
44
61
|
resolver:resolve
|
|
45
62
|
rejecter:reject];
|
|
46
63
|
}
|
package/ios/AdgeistImpl.swift
CHANGED
|
@@ -5,12 +5,21 @@ import React
|
|
|
5
5
|
@objc public class AdgeistImpl: NSObject {
|
|
6
6
|
private static let adGeist = AdgeistCore.shared
|
|
7
7
|
@objc public func fetchCreative(
|
|
8
|
+
apiKey: String,
|
|
9
|
+
origin: String,
|
|
8
10
|
adSpaceId: String,
|
|
9
11
|
publisherId: String,
|
|
12
|
+
isTestEnvironment: Bool,
|
|
10
13
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
11
14
|
rejecter: @escaping RCTPromiseRejectBlock
|
|
12
15
|
) {
|
|
13
|
-
AdgeistImpl.adGeist.getCreative().fetchCreative(
|
|
16
|
+
AdgeistImpl.adGeist.getCreative().fetchCreative(
|
|
17
|
+
apiKey: apiKey,
|
|
18
|
+
origin: origin,
|
|
19
|
+
adSpaceId: adSpaceId,
|
|
20
|
+
companyId: publisherId,
|
|
21
|
+
isTestEnvironment: isTestEnvironment
|
|
22
|
+
) { creativeData in
|
|
14
23
|
if let creativeData = creativeData {
|
|
15
24
|
do {
|
|
16
25
|
let encoder = JSONEncoder()
|
|
@@ -34,6 +43,10 @@ import React
|
|
|
34
43
|
adSpaceId: String,
|
|
35
44
|
publisherId: String,
|
|
36
45
|
eventType: String,
|
|
46
|
+
origin: String,
|
|
47
|
+
apiKey: String,
|
|
48
|
+
bidId: String,
|
|
49
|
+
isTestEnvironment: Bool,
|
|
37
50
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
38
51
|
rejecter: @escaping RCTPromiseRejectBlock
|
|
39
52
|
) {
|
|
@@ -41,7 +54,11 @@ import React
|
|
|
41
54
|
campaignId: campaignId,
|
|
42
55
|
adSpaceId: adSpaceId,
|
|
43
56
|
publisherId: publisherId,
|
|
44
|
-
eventType: eventType
|
|
57
|
+
eventType: eventType,
|
|
58
|
+
origin: origin,
|
|
59
|
+
apiKey: apiKey,
|
|
60
|
+
bidId: bidId,
|
|
61
|
+
isTestEnvironment: isTestEnvironment
|
|
45
62
|
) { response in
|
|
46
63
|
if let response = response {
|
|
47
64
|
resolver(response)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { Dimensions, Image, Linking, StyleSheet, Text, View, TouchableWithoutFeedback } from 'react-native';
|
|
4
|
+
import { Dimensions, Image, Linking, StyleSheet, Text, View, TouchableWithoutFeedback, ActivityIndicator } from 'react-native';
|
|
5
5
|
import Adgeist from "../NativeAdgeist.js";
|
|
6
6
|
import { useAdgeistContext } from "./AdgeistProvider.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -9,6 +9,7 @@ export const BannerAd = ({
|
|
|
9
9
|
dataAdSlot
|
|
10
10
|
}) => {
|
|
11
11
|
const [adData, setAdData] = useState(null);
|
|
12
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
12
13
|
const {
|
|
13
14
|
publisherId,
|
|
14
15
|
apiKey,
|
|
@@ -19,9 +20,11 @@ export const BannerAd = ({
|
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
(async () => {
|
|
21
22
|
try {
|
|
23
|
+
setIsLoading(true);
|
|
22
24
|
const response = await Adgeist.fetchCreative(apiKey, domain, dataAdSlot, publisherId, isTestEnvironment);
|
|
23
25
|
const creative = response;
|
|
24
26
|
setAdData(creative.data);
|
|
27
|
+
setIsLoading(false);
|
|
25
28
|
if (creative.data.seatBid.length > 0) {
|
|
26
29
|
await Adgeist.sendCreativeAnalytic(creative.data.seatBid?.[0]?.bid?.[0]?.id || '', dataAdSlot, publisherId, 'IMPRESSION', domain, apiKey, creative.data.id, isTestEnvironment);
|
|
27
30
|
}
|
|
@@ -36,6 +39,15 @@ export const BannerAd = ({
|
|
|
36
39
|
Linking.openURL(creativeData.ctaUrl).catch(err => console.error('Failed to open URL:', err));
|
|
37
40
|
}
|
|
38
41
|
};
|
|
42
|
+
if (isLoading) {
|
|
43
|
+
return /*#__PURE__*/_jsx(View, {
|
|
44
|
+
style: styles.loadingOverlayContainer,
|
|
45
|
+
children: /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
46
|
+
size: "large",
|
|
47
|
+
color: "#63AA75"
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
39
51
|
if (!creativeData?.creativeUrl) return null;
|
|
40
52
|
return /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
41
53
|
accessible: true,
|
|
@@ -93,6 +105,12 @@ const styles = StyleSheet.create({
|
|
|
93
105
|
backgroundColor: 'white',
|
|
94
106
|
borderRadius: 5
|
|
95
107
|
},
|
|
108
|
+
loadingOverlayContainer: {
|
|
109
|
+
width: '100%',
|
|
110
|
+
height: 375,
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center'
|
|
113
|
+
},
|
|
96
114
|
creative: {
|
|
97
115
|
resizeMode: 'cover',
|
|
98
116
|
borderTopLeftRadius: 5,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","Dimensions","Image","Linking","StyleSheet","Text","View","TouchableWithoutFeedback","Adgeist","useAdgeistContext","jsx","_jsx","jsxs","_jsxs","BannerAd","dataAdSlot","adData","setAdData","publisherId","apiKey","domain","isTestEnvironment","creativeData","seatBid","bid","ext","response","fetchCreative","creative","data","length","sendCreativeAnalytic","id","error","console","handleClick","openURL","ctaUrl","catch","err","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","Dimensions","Image","Linking","StyleSheet","Text","View","TouchableWithoutFeedback","ActivityIndicator","Adgeist","useAdgeistContext","jsx","_jsx","jsxs","_jsxs","BannerAd","dataAdSlot","adData","setAdData","isLoading","setIsLoading","publisherId","apiKey","domain","isTestEnvironment","creativeData","seatBid","bid","ext","response","fetchCreative","creative","data","length","sendCreativeAnalytic","id","error","console","handleClick","openURL","ctaUrl","catch","err","style","styles","loadingOverlayContainer","children","size","color","creativeUrl","accessible","accessibilityLabel","adContainer","width","height","source","uri","adContent","contentContainer","title","numberOfLines","ellipsizeMode","creativeTitle","description","creativeDescription","brandName","creativeBrandName","onPress","linkButton","create","get","backgroundColor","borderRadius","alignItems","justifyContent","resizeMode","borderTopLeftRadius","borderTopRightRadius","flexDirection","paddingVertical","paddingHorizontal","borderBottomLeftRadius","borderBottomRightRadius","fontSize","fontWeight","opacity","marginTop"],"sourceRoot":"../../../src","sources":["components/BannerAd.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SACEC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,UAAU,EACVC,IAAI,EACJC,IAAI,EACJC,wBAAwB,EACxBC,iBAAiB,QACZ,cAAc;AACrB,OAAOC,OAAO,MAAM,qBAAkB;AACtC,SAASC,iBAAiB,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAkCtD,OAAO,MAAMC,QAAiC,GAAGA,CAAC;EAAEC;AAAW,CAAC,KAAK;EACnE,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGlB,QAAQ,CAAgB,IAAI,CAAC;EACzD,MAAM,CAACmB,SAAS,EAAEC,YAAY,CAAC,GAAGpB,QAAQ,CAAC,KAAK,CAAC;EACjD,MAAM;IAAEqB,WAAW;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAkB,CAAC,GACtDd,iBAAiB,CAAC,CAAC;EAErB,MAAMe,YAAY,GAAGR,MAAM,EAAES,OAAO,GAAG,CAAC,CAAC,EAAEC,GAAG,GAAG,CAAC,CAAC,EAAEC,GAAmB;EAExE7B,SAAS,CAAC,MAAM;IACd,CAAC,YAAY;MACX,IAAI;QACFqB,YAAY,CAAC,IAAI,CAAC;QAClB,MAAMS,QAAgB,GAAG,MAAMpB,OAAO,CAACqB,aAAa,CAClDR,MAAM,EACNC,MAAM,EACNP,UAAU,EACVK,WAAW,EACXG,iBACF,CAAC;QAED,MAAMO,QAA0B,GAAGF,QAA4B;QAC/DX,SAAS,CAACa,QAAQ,CAACC,IAAI,CAAC;QACxBZ,YAAY,CAAC,KAAK,CAAC;QAEnB,IAAIW,QAAQ,CAACC,IAAI,CAACN,OAAO,CAACO,MAAM,GAAG,CAAC,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AW,EAAE;IACXf,KAAK,EAAE,OAAO;IACdmC,QAAQ,EAAE;EACZ,CAAC;EACDlB,SAAS,EAAE;IACTjB,KAAK,EAAE,OAAO;IACdmC,QAAQ,EAAE,EAAE;IACZE,OAAO,EAAE,GAAG;IACZC,SAAS,EAAE,CAAC;IACZF,UAAU,EAAE;EACd,CAAC;EACDhB,UAAU,EAAE;IACVf,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerAd.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerAd.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAwCnD,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAqH5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thealteroffice/react-native-adgeist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
View,
|
|
9
9
|
TouchableWithoutFeedback,
|
|
10
|
+
ActivityIndicator,
|
|
10
11
|
} from 'react-native';
|
|
11
12
|
import Adgeist from '../NativeAdgeist';
|
|
12
13
|
import { useAdgeistContext } from './AdgeistProvider';
|
|
@@ -45,6 +46,7 @@ interface AdBannerTypes {
|
|
|
45
46
|
|
|
46
47
|
export const BannerAd: React.FC<AdBannerTypes> = ({ dataAdSlot }) => {
|
|
47
48
|
const [adData, setAdData] = useState<AdData | null>(null);
|
|
49
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
48
50
|
const { publisherId, apiKey, domain, isTestEnvironment } =
|
|
49
51
|
useAdgeistContext();
|
|
50
52
|
|
|
@@ -53,6 +55,7 @@ export const BannerAd: React.FC<AdBannerTypes> = ({ dataAdSlot }) => {
|
|
|
53
55
|
useEffect(() => {
|
|
54
56
|
(async () => {
|
|
55
57
|
try {
|
|
58
|
+
setIsLoading(true);
|
|
56
59
|
const response: Object = await Adgeist.fetchCreative(
|
|
57
60
|
apiKey,
|
|
58
61
|
domain,
|
|
@@ -63,6 +66,7 @@ export const BannerAd: React.FC<AdBannerTypes> = ({ dataAdSlot }) => {
|
|
|
63
66
|
|
|
64
67
|
const creative: { data: AdData } = response as { data: AdData };
|
|
65
68
|
setAdData(creative.data);
|
|
69
|
+
setIsLoading(false);
|
|
66
70
|
|
|
67
71
|
if (creative.data.seatBid.length > 0) {
|
|
68
72
|
await Adgeist.sendCreativeAnalytic(
|
|
@@ -100,6 +104,14 @@ export const BannerAd: React.FC<AdBannerTypes> = ({ dataAdSlot }) => {
|
|
|
100
104
|
}
|
|
101
105
|
};
|
|
102
106
|
|
|
107
|
+
if (isLoading) {
|
|
108
|
+
return (
|
|
109
|
+
<View style={styles.loadingOverlayContainer}>
|
|
110
|
+
<ActivityIndicator size="large" color="#63AA75" />
|
|
111
|
+
</View>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
if (!creativeData?.creativeUrl) return null;
|
|
104
116
|
|
|
105
117
|
return (
|
|
@@ -157,6 +169,12 @@ const styles = StyleSheet.create({
|
|
|
157
169
|
backgroundColor: 'white',
|
|
158
170
|
borderRadius: 5,
|
|
159
171
|
},
|
|
172
|
+
loadingOverlayContainer: {
|
|
173
|
+
width: '100%',
|
|
174
|
+
height: 375,
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
justifyContent: 'center',
|
|
177
|
+
},
|
|
160
178
|
creative: {
|
|
161
179
|
resizeMode: 'cover',
|
|
162
180
|
borderTopLeftRadius: 5,
|