@thealteroffice/react-native-adgeist 0.0.1
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 +28 -0
- package/LICENSE +20 -0
- package/README.md +65 -0
- package/android/build.gradle +101 -0
- package/android/generated/java/com/adgeist/NativeAdgeistSpec.java +42 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNAdgeistSpec-generated.cpp +38 -0
- package/android/generated/jni/RNAdgeistSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp +38 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI.h +80 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/adgeist/AdgeistModule.kt +89 -0
- package/android/src/main/java/com/adgeist/AdgeistPackage.kt +33 -0
- package/ios/Adgeist.h +18 -0
- package/ios/Adgeist.mm +52 -0
- package/ios/AdgeistImpl.swift +57 -0
- package/ios/adgeist-Bridging-Header.h +2 -0
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +46 -0
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +71 -0
- package/ios/generated/RNAdgeistSpecJSI-generated.cpp +38 -0
- package/ios/generated/RNAdgeistSpecJSI.h +80 -0
- package/lib/module/NativeAdgeist.ts +14 -0
- package/lib/module/components/BannerAd.js +176 -0
- package/lib/module/components/BannerAd.js.map +1 -0
- package/lib/module/components/BottomBannerAd.js +150 -0
- package/lib/module/components/BottomBannerAd.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeAdgeist.d.ts +8 -0
- package/lib/typescript/src/NativeAdgeist.d.ts.map +1 -0
- package/lib/typescript/src/components/BannerAd.d.ts +10 -0
- package/lib/typescript/src/components/BannerAd.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomBannerAd.d.ts +8 -0
- package/lib/typescript/src/components/BottomBannerAd.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +170 -0
- package/react-native.config.js +12 -0
- package/src/NativeAdgeist.ts +14 -0
- package/src/components/BannerAd.tsx +202 -0
- package/src/components/BottomBannerAd.tsx +185 -0
- package/src/index.tsx +2 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Image,
|
|
5
|
+
Linking,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Text,
|
|
8
|
+
View,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
TouchableWithoutFeedback,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import Adgeist from '../NativeAdgeist';
|
|
13
|
+
|
|
14
|
+
interface Creative {
|
|
15
|
+
fileUrl: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description: string;
|
|
18
|
+
ctaUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AdData {
|
|
22
|
+
_id: string;
|
|
23
|
+
creative: Creative;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface AdBannerTypes {
|
|
27
|
+
dataPublisherId: string;
|
|
28
|
+
dataAdSlot: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const BottomBannerAd: React.FC<AdBannerTypes> = ({
|
|
32
|
+
dataPublisherId,
|
|
33
|
+
dataAdSlot,
|
|
34
|
+
}) => {
|
|
35
|
+
const [adData, setAdData] = useState<AdData | null>(null);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
(async () => {
|
|
39
|
+
try {
|
|
40
|
+
const response: Object = await Adgeist.fetchCreative(
|
|
41
|
+
dataAdSlot,
|
|
42
|
+
dataPublisherId
|
|
43
|
+
);
|
|
44
|
+
const creative: { data: AdData } = response as { data: AdData };
|
|
45
|
+
setAdData(creative.data);
|
|
46
|
+
await Adgeist.sendCreativeAnalytic(
|
|
47
|
+
creative.data._id,
|
|
48
|
+
dataAdSlot,
|
|
49
|
+
dataPublisherId,
|
|
50
|
+
'impression'
|
|
51
|
+
);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('Ad load failed:', error);
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
}, [dataPublisherId, dataAdSlot]);
|
|
57
|
+
|
|
58
|
+
const handleClick = async () => {
|
|
59
|
+
if (adData?.creative?.ctaUrl) {
|
|
60
|
+
await Adgeist.sendCreativeAnalytic(
|
|
61
|
+
adData._id,
|
|
62
|
+
dataAdSlot,
|
|
63
|
+
dataPublisherId,
|
|
64
|
+
'click'
|
|
65
|
+
);
|
|
66
|
+
Linking.openURL(adData.creative.ctaUrl).catch((err) =>
|
|
67
|
+
console.error('Failed to open URL:', err)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (!adData?.creative?.fileUrl) return null;
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<TouchableWithoutFeedback
|
|
76
|
+
style={styles.container}
|
|
77
|
+
onPress={handleClick}
|
|
78
|
+
accessible
|
|
79
|
+
accessibilityLabel="Ad Banner"
|
|
80
|
+
>
|
|
81
|
+
<View style={styles.adContent}>
|
|
82
|
+
<Image style={styles.logo} source={{ uri: adData.creative.fileUrl }} />
|
|
83
|
+
<View style={styles.textContainer}>
|
|
84
|
+
<View style={styles.titleRow}>
|
|
85
|
+
<Text style={styles.adBadge}>AD</Text>
|
|
86
|
+
<Text style={styles.title} numberOfLines={1} ellipsizeMode="tail">
|
|
87
|
+
{adData.creative.title}
|
|
88
|
+
</Text>
|
|
89
|
+
</View>
|
|
90
|
+
<Text
|
|
91
|
+
style={styles.description}
|
|
92
|
+
numberOfLines={1}
|
|
93
|
+
ellipsizeMode="tail"
|
|
94
|
+
>
|
|
95
|
+
{adData.creative.description}
|
|
96
|
+
</Text>
|
|
97
|
+
</View>
|
|
98
|
+
<TouchableOpacity
|
|
99
|
+
style={styles.button}
|
|
100
|
+
onPress={handleClick}
|
|
101
|
+
accessible
|
|
102
|
+
accessibilityLabel="Visit Site Button"
|
|
103
|
+
>
|
|
104
|
+
<Text style={styles.buttonText}>Visit Site</Text>
|
|
105
|
+
</TouchableOpacity>
|
|
106
|
+
</View>
|
|
107
|
+
</TouchableWithoutFeedback>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const styles = StyleSheet.create({
|
|
112
|
+
container: {
|
|
113
|
+
backgroundColor: 'white',
|
|
114
|
+
borderRadius: 10,
|
|
115
|
+
},
|
|
116
|
+
creative: {
|
|
117
|
+
resizeMode: 'contain',
|
|
118
|
+
borderTopLeftRadius: 10,
|
|
119
|
+
borderTopRightRadius: 10,
|
|
120
|
+
},
|
|
121
|
+
options: {
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
gap: 2,
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
top: 5,
|
|
126
|
+
left: 5,
|
|
127
|
+
},
|
|
128
|
+
option: {
|
|
129
|
+
color: 'green',
|
|
130
|
+
backgroundColor: '#00000022',
|
|
131
|
+
width: 20,
|
|
132
|
+
height: 20,
|
|
133
|
+
textAlign: 'center',
|
|
134
|
+
},
|
|
135
|
+
adContent: {
|
|
136
|
+
width: '100%',
|
|
137
|
+
backgroundColor: 'white',
|
|
138
|
+
flexDirection: 'row',
|
|
139
|
+
justifyContent: 'space-between',
|
|
140
|
+
paddingHorizontal: 10,
|
|
141
|
+
paddingVertical: 10,
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
},
|
|
144
|
+
logo: {
|
|
145
|
+
width: 35,
|
|
146
|
+
height: 35,
|
|
147
|
+
resizeMode: 'contain',
|
|
148
|
+
borderRadius: 2,
|
|
149
|
+
},
|
|
150
|
+
textContainer: {
|
|
151
|
+
width: Dimensions.get('window').width - 150,
|
|
152
|
+
},
|
|
153
|
+
titleRow: {
|
|
154
|
+
flexDirection: 'row',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
gap: 5,
|
|
157
|
+
width: Dimensions.get('window').width - 200,
|
|
158
|
+
},
|
|
159
|
+
adBadge: {
|
|
160
|
+
color: 'white',
|
|
161
|
+
backgroundColor: 'green',
|
|
162
|
+
width: 40,
|
|
163
|
+
borderRadius: 4,
|
|
164
|
+
textAlign: 'center',
|
|
165
|
+
},
|
|
166
|
+
title: {
|
|
167
|
+
color: 'black',
|
|
168
|
+
},
|
|
169
|
+
description: {
|
|
170
|
+
color: 'black',
|
|
171
|
+
},
|
|
172
|
+
button: {
|
|
173
|
+
paddingHorizontal: 10,
|
|
174
|
+
paddingVertical: 5,
|
|
175
|
+
borderWidth: 1,
|
|
176
|
+
borderColor: 'green',
|
|
177
|
+
borderRadius: 5,
|
|
178
|
+
alignItems: 'center',
|
|
179
|
+
justifyContent: 'center',
|
|
180
|
+
height: 40,
|
|
181
|
+
},
|
|
182
|
+
buttonText: {
|
|
183
|
+
color: 'green',
|
|
184
|
+
},
|
|
185
|
+
});
|
package/src/index.tsx
ADDED