@vynix-org/react-native-ads-sdk 0.1.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/AdsSdk.podspec +52 -0
- package/LICENSE +20 -0
- package/README.md +95 -0
- package/android/build.gradle +108 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/adssdk/AdsSdkModule.kt +23 -0
- package/android/src/main/java/com/adssdk/AdsSdkPackage.kt +33 -0
- package/ios/AdsSdk.h +5 -0
- package/ios/AdsSdk.mm +18 -0
- package/lib/module/ads-manager/AppOpenAdsManager.js +131 -0
- package/lib/module/ads-manager/AppOpenAdsManager.js.map +1 -0
- package/lib/module/ads-manager/GoogleMobileAdsManager.js +62 -0
- package/lib/module/ads-manager/GoogleMobileAdsManager.js.map +1 -0
- package/lib/module/ads-manager/InterstitialAdsManager.js +291 -0
- package/lib/module/ads-manager/InterstitialAdsManager.js.map +1 -0
- package/lib/module/ads-manager/NativeAdsManager.js +405 -0
- package/lib/module/ads-manager/NativeAdsManager.js.map +1 -0
- package/lib/module/ads-manager/RewardedAdsManager.js +328 -0
- package/lib/module/ads-manager/RewardedAdsManager.js.map +1 -0
- package/lib/module/ads-manager/RewardedInterstitialAdsManager.js +328 -0
- package/lib/module/ads-manager/RewardedInterstitialAdsManager.js.map +1 -0
- package/lib/module/components/BannerAdComponent.js +159 -0
- package/lib/module/components/BannerAdComponent.js.map +1 -0
- package/lib/module/components/FullscreenStyles.js +162 -0
- package/lib/module/components/FullscreenStyles.js.map +1 -0
- package/lib/module/components/NativeAdComponent.js +172 -0
- package/lib/module/components/NativeAdComponent.js.map +1 -0
- package/lib/module/components/NativeAdFullscreenComponent.js +205 -0
- package/lib/module/components/NativeAdFullscreenComponent.js.map +1 -0
- package/lib/module/components/NativeStyles.js +143 -0
- package/lib/module/components/NativeStyles.js.map +1 -0
- package/lib/module/event/custom-event.js +29 -0
- package/lib/module/event/custom-event.js.map +1 -0
- package/lib/module/hook/useAppOpenAd.js +138 -0
- package/lib/module/hook/useAppOpenAd.js.map +1 -0
- package/lib/module/hook/useInterstitialAd.js +157 -0
- package/lib/module/hook/useInterstitialAd.js.map +1 -0
- package/lib/module/hook/useNativeAd.js +147 -0
- package/lib/module/hook/useNativeAd.js.map +1 -0
- package/lib/module/hook/useRewardedAd.js +166 -0
- package/lib/module/hook/useRewardedAd.js.map +1 -0
- package/lib/module/hook/useRewardedInterstitialAd.js +166 -0
- package/lib/module/hook/useRewardedInterstitialAd.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/stores/interstitial-ads-store.js +205 -0
- package/lib/module/stores/interstitial-ads-store.js.map +1 -0
- package/lib/module/stores/native-ads-store.js +204 -0
- package/lib/module/stores/native-ads-store.js.map +1 -0
- package/lib/module/stores/rewarded-ads-store.js +216 -0
- package/lib/module/stores/rewarded-ads-store.js.map +1 -0
- package/lib/module/stores/rewarded-interstitial-ads-store.js +216 -0
- package/lib/module/stores/rewarded-interstitial-ads-store.js.map +1 -0
- package/lib/module/types/ads-types.js +25 -0
- package/lib/module/types/ads-types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ads-manager/AppOpenAdsManager.d.ts +38 -0
- package/lib/typescript/src/ads-manager/AppOpenAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/ads-manager/GoogleMobileAdsManager.d.ts +22 -0
- package/lib/typescript/src/ads-manager/GoogleMobileAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/ads-manager/InterstitialAdsManager.d.ts +22 -0
- package/lib/typescript/src/ads-manager/InterstitialAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/ads-manager/NativeAdsManager.d.ts +59 -0
- package/lib/typescript/src/ads-manager/NativeAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/ads-manager/RewardedAdsManager.d.ts +25 -0
- package/lib/typescript/src/ads-manager/RewardedAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/ads-manager/RewardedInterstitialAdsManager.d.ts +25 -0
- package/lib/typescript/src/ads-manager/RewardedInterstitialAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/components/BannerAdComponent.d.ts +22 -0
- package/lib/typescript/src/components/BannerAdComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/FullscreenStyles.d.ts +155 -0
- package/lib/typescript/src/components/FullscreenStyles.d.ts.map +1 -0
- package/lib/typescript/src/components/NativeAdComponent.d.ts +24 -0
- package/lib/typescript/src/components/NativeAdComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/NativeAdFullscreenComponent.d.ts +26 -0
- package/lib/typescript/src/components/NativeAdFullscreenComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/NativeStyles.d.ts +139 -0
- package/lib/typescript/src/components/NativeStyles.d.ts.map +1 -0
- package/lib/typescript/src/event/custom-event.d.ts +8 -0
- package/lib/typescript/src/event/custom-event.d.ts.map +1 -0
- package/lib/typescript/src/hook/useAppOpenAd.d.ts +19 -0
- package/lib/typescript/src/hook/useAppOpenAd.d.ts.map +1 -0
- package/lib/typescript/src/hook/useInterstitialAd.d.ts +20 -0
- package/lib/typescript/src/hook/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/src/hook/useNativeAd.d.ts +20 -0
- package/lib/typescript/src/hook/useNativeAd.d.ts.map +1 -0
- package/lib/typescript/src/hook/useRewardedAd.d.ts +27 -0
- package/lib/typescript/src/hook/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/src/hook/useRewardedInterstitialAd.d.ts +27 -0
- package/lib/typescript/src/hook/useRewardedInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/stores/interstitial-ads-store.d.ts +36 -0
- package/lib/typescript/src/stores/interstitial-ads-store.d.ts.map +1 -0
- package/lib/typescript/src/stores/native-ads-store.d.ts +36 -0
- package/lib/typescript/src/stores/native-ads-store.d.ts.map +1 -0
- package/lib/typescript/src/stores/rewarded-ads-store.d.ts +39 -0
- package/lib/typescript/src/stores/rewarded-ads-store.d.ts.map +1 -0
- package/lib/typescript/src/stores/rewarded-interstitial-ads-store.d.ts +39 -0
- package/lib/typescript/src/stores/rewarded-interstitial-ads-store.d.ts.map +1 -0
- package/lib/typescript/src/types/ads-types.d.ts +164 -0
- package/lib/typescript/src/types/ads-types.d.ts.map +1 -0
- package/package.json +177 -0
- package/src/ads-manager/AppOpenAdsManager.ts +155 -0
- package/src/ads-manager/GoogleMobileAdsManager.ts +68 -0
- package/src/ads-manager/InterstitialAdsManager.ts +371 -0
- package/src/ads-manager/NativeAdsManager.ts +445 -0
- package/src/ads-manager/RewardedAdsManager.ts +383 -0
- package/src/ads-manager/RewardedInterstitialAdsManager.ts +410 -0
- package/src/components/BannerAdComponent.tsx +205 -0
- package/src/components/FullscreenStyles.ts +158 -0
- package/src/components/NativeAdComponent.tsx +208 -0
- package/src/components/NativeAdFullscreenComponent.tsx +261 -0
- package/src/components/NativeStyles.ts +141 -0
- package/src/event/custom-event.ts +30 -0
- package/src/hook/useAppOpenAd.ts +161 -0
- package/src/hook/useInterstitialAd.ts +195 -0
- package/src/hook/useNativeAd.ts +173 -0
- package/src/hook/useRewardedAd.ts +205 -0
- package/src/hook/useRewardedInterstitialAd.ts +212 -0
- package/src/index.tsx +33 -0
- package/src/stores/interstitial-ads-store.ts +287 -0
- package/src/stores/native-ads-store.ts +272 -0
- package/src/stores/rewarded-ads-store.ts +290 -0
- package/src/stores/rewarded-interstitial-ads-store.ts +318 -0
- package/src/types/ads-types.ts +239 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
export enum AdStatus {
|
|
2
|
+
IDLE = 'idle',
|
|
3
|
+
LOADING = 'loading',
|
|
4
|
+
LOADED = 'loaded',
|
|
5
|
+
DISPLAYED = 'displayed',
|
|
6
|
+
ERROR = 'error',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AdConfig {
|
|
10
|
+
adId: string;
|
|
11
|
+
adKey: string;
|
|
12
|
+
timeout?: number; // milliseconds
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
adHighpriorityId?: string; // Thêm field này
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AdData {
|
|
18
|
+
id: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
imageUrl?: string;
|
|
22
|
+
callToAction?: string;
|
|
23
|
+
advertiser?: string;
|
|
24
|
+
rating?: number;
|
|
25
|
+
price?: string;
|
|
26
|
+
store?: string;
|
|
27
|
+
// Google Mobile Ads specific fields
|
|
28
|
+
iconUrl?: string;
|
|
29
|
+
images?: string[];
|
|
30
|
+
videoUrl?: string;
|
|
31
|
+
socialContext?: string;
|
|
32
|
+
nativeAd?: any; // Reference đến native ad object từ react-native-google-mobile-ads
|
|
33
|
+
// Custom data từ native ads
|
|
34
|
+
[adKey: string]: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface AdInstance {
|
|
38
|
+
adKey: string;
|
|
39
|
+
adId: string;
|
|
40
|
+
status: AdStatus;
|
|
41
|
+
data: AdData | null;
|
|
42
|
+
error: string | null;
|
|
43
|
+
loadTime: number | null;
|
|
44
|
+
displayTime: number | null;
|
|
45
|
+
retryCount: number;
|
|
46
|
+
isUsingHighPriority?: boolean; // Track xem đang load high priority hay không
|
|
47
|
+
hasTriedHighPriority?: boolean; // Track xem đã thử high priority chưa
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AdManagerState {
|
|
51
|
+
ads: Map<string, AdInstance>;
|
|
52
|
+
loadingKeys: Set<string>;
|
|
53
|
+
displayedKeys: Set<string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface AdManagerActions {
|
|
57
|
+
preloadAd: (
|
|
58
|
+
adKey: string,
|
|
59
|
+
adId: string,
|
|
60
|
+
config?: Partial<AdConfig>
|
|
61
|
+
) => Promise<void>;
|
|
62
|
+
loadAd: (
|
|
63
|
+
adKey: string,
|
|
64
|
+
adId: string,
|
|
65
|
+
config?: Partial<AdConfig>
|
|
66
|
+
) => Promise<void>;
|
|
67
|
+
displayAd: (adKey: string) => Promise<AdInstance | null>;
|
|
68
|
+
getAd: (adKey: string) => AdInstance | null;
|
|
69
|
+
removeAd: (adKey: string) => void;
|
|
70
|
+
clearAllAds: () => void;
|
|
71
|
+
refreshAd: (adKey: string) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface AdManagerContextType
|
|
75
|
+
extends AdManagerState,
|
|
76
|
+
AdManagerActions {}
|
|
77
|
+
|
|
78
|
+
export interface UseAdOptions {
|
|
79
|
+
autoLoad?: boolean;
|
|
80
|
+
autoRefresh?: boolean;
|
|
81
|
+
refreshInterval?: number; // milliseconds
|
|
82
|
+
onLoad?: (ad: AdInstance) => void;
|
|
83
|
+
onDisplay?: (ad: AdInstance) => void;
|
|
84
|
+
onError?: (error: string, ad: AdInstance) => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Banner Ad Types
|
|
88
|
+
export interface BannerAdConfig extends AdConfig {
|
|
89
|
+
size?:
|
|
90
|
+
| 'BANNER'
|
|
91
|
+
| 'LARGE_BANNER'
|
|
92
|
+
| 'MEDIUM_RECTANGLE'
|
|
93
|
+
| 'FULL_BANNER'
|
|
94
|
+
| 'LEADERBOARD'
|
|
95
|
+
| 'ANCHORED_ADAPTIVE_BANNER';
|
|
96
|
+
position?: 'top' | 'bottom';
|
|
97
|
+
margin?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface BannerAdInstance extends AdInstance {
|
|
101
|
+
type: 'banner';
|
|
102
|
+
config: BannerAdConfig;
|
|
103
|
+
bannerAd?: any; // Reference đến banner ad object
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Interstitial Ad Types
|
|
107
|
+
export interface InterstitialAdConfig extends AdConfig {
|
|
108
|
+
showOnAppStateChange?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface InterstitialAdInstance extends AdInstance {
|
|
112
|
+
type: 'interstitial';
|
|
113
|
+
config: InterstitialAdConfig;
|
|
114
|
+
interstitialAd?: any; // Reference đến interstitial ad object
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Rewarded Ad Types
|
|
118
|
+
export interface RewardedAdConfig extends AdConfig {
|
|
119
|
+
showOnAppStateChange?: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface RewardedAdInstance extends AdInstance {
|
|
123
|
+
type: 'rewarded';
|
|
124
|
+
config: RewardedAdConfig;
|
|
125
|
+
rewardedAd?: any; // Reference đến rewarded ad object
|
|
126
|
+
reward?: {
|
|
127
|
+
type: string;
|
|
128
|
+
amount: number;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Rewarded Interstitial Ad Types
|
|
133
|
+
export interface RewardedInterstitialAdConfig extends AdConfig {
|
|
134
|
+
showOnAppStateChange?: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface RewardedInterstitialAdInstance extends AdInstance {
|
|
138
|
+
type: 'rewarded_interstitial';
|
|
139
|
+
config: RewardedInterstitialAdConfig;
|
|
140
|
+
rewardedInterstitialAd?: any; // Reference đến rewarded interstitial ad object
|
|
141
|
+
reward?: {
|
|
142
|
+
type: string;
|
|
143
|
+
amount: number;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Union type cho tất cả các loại quảng cáo
|
|
148
|
+
export type AnyAdInstance =
|
|
149
|
+
| AdInstance
|
|
150
|
+
| BannerAdInstance
|
|
151
|
+
| InterstitialAdInstance
|
|
152
|
+
| RewardedAdInstance
|
|
153
|
+
| RewardedInterstitialAdInstance;
|
|
154
|
+
|
|
155
|
+
export type AdType =
|
|
156
|
+
| 'native'
|
|
157
|
+
| 'banner'
|
|
158
|
+
| 'interstitial'
|
|
159
|
+
| 'rewarded'
|
|
160
|
+
| 'rewarded_interstitial';
|
|
161
|
+
|
|
162
|
+
// Generic Ad Manager Types
|
|
163
|
+
export interface GenericAdManagerState {
|
|
164
|
+
ads: Map<string, AnyAdInstance>;
|
|
165
|
+
loadingKeys: Set<string>;
|
|
166
|
+
displayedKeys: Set<string>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface GenericAdManagerActions {
|
|
170
|
+
preloadAd: (
|
|
171
|
+
adKey: string,
|
|
172
|
+
adId: string,
|
|
173
|
+
adType: AdType,
|
|
174
|
+
config?: Partial<
|
|
175
|
+
| AdConfig
|
|
176
|
+
| BannerAdConfig
|
|
177
|
+
| InterstitialAdConfig
|
|
178
|
+
| RewardedAdConfig
|
|
179
|
+
| RewardedInterstitialAdConfig
|
|
180
|
+
>
|
|
181
|
+
) => Promise<void>;
|
|
182
|
+
loadAd: (
|
|
183
|
+
adKey: string,
|
|
184
|
+
adId: string,
|
|
185
|
+
adType: AdType,
|
|
186
|
+
config?: Partial<
|
|
187
|
+
| AdConfig
|
|
188
|
+
| BannerAdConfig
|
|
189
|
+
| InterstitialAdConfig
|
|
190
|
+
| RewardedAdConfig
|
|
191
|
+
| RewardedInterstitialAdConfig
|
|
192
|
+
>
|
|
193
|
+
) => Promise<void>;
|
|
194
|
+
displayAd: (adKey: string) => Promise<AnyAdInstance | null>;
|
|
195
|
+
getAd: (adKey: string) => AnyAdInstance | null;
|
|
196
|
+
removeAd: (adKey: string) => void;
|
|
197
|
+
clearAllAds: () => void;
|
|
198
|
+
refreshAd: (adKey: string) => Promise<void>;
|
|
199
|
+
clearAdsByType: (adType: AdType) => void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface GenericAdManagerContextType
|
|
203
|
+
extends GenericAdManagerState,
|
|
204
|
+
GenericAdManagerActions {}
|
|
205
|
+
|
|
206
|
+
// Hook options cho các loại ads khác
|
|
207
|
+
export interface UseBannerAdOptions extends UseAdOptions {
|
|
208
|
+
size?: BannerAdConfig['size'];
|
|
209
|
+
position?: BannerAdConfig['position'];
|
|
210
|
+
margin?: BannerAdConfig['margin'];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface UseInterstitialAdOptions extends UseAdOptions {
|
|
214
|
+
showOnAppStateChange?: boolean;
|
|
215
|
+
onOpened?: (ad: InterstitialAdInstance) => void;
|
|
216
|
+
onClicked?: (ad: InterstitialAdInstance) => void;
|
|
217
|
+
onClosed?: (ad: InterstitialAdInstance) => void;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface UseRewardedAdOptions extends UseAdOptions {
|
|
221
|
+
showOnAppStateChange?: boolean;
|
|
222
|
+
onReward?: (reward: { type: string; amount: number }) => void;
|
|
223
|
+
onOpened?: (ad: RewardedAdInstance) => void;
|
|
224
|
+
onClicked?: (ad: RewardedAdInstance) => void;
|
|
225
|
+
onClosed?: (ad: RewardedAdInstance) => void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface UseRewardedInterstitialAdOptions extends UseAdOptions {
|
|
229
|
+
showOnAppStateChange?: boolean;
|
|
230
|
+
onReward?: (reward: { type: string; amount: number }) => void;
|
|
231
|
+
onOpened?: (ad: RewardedInterstitialAdInstance) => void;
|
|
232
|
+
onClicked?: (ad: RewardedInterstitialAdInstance) => void;
|
|
233
|
+
onClosed?: (ad: RewardedInterstitialAdInstance) => void;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface UseNativeAdOptions extends UseAdOptions {
|
|
237
|
+
onClicked?: (ad: AdInstance) => void; // Thêm callback cho click event
|
|
238
|
+
onImpression?: (ad: AdInstance) => void; // Thêm callback cho impression event
|
|
239
|
+
}
|