@advergic-ads/react-native-sdk 1.0.0
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/AdvergicReactNative.podspec +32 -0
- package/LICENSE +21 -0
- package/README.md +329 -0
- package/android/advergic-bridge/build.gradle +58 -0
- package/android/advergic-bridge/libs/advergic-sdk.aar +0 -0
- package/android/advergic-bridge/src/main/java/com/advergic/reactnative/AdvergicBannerViewManager.kt +194 -0
- package/android/advergic-bridge/src/main/java/com/advergic/reactnative/AdvergicReactNativeModule.java +401 -0
- package/android/advergic-bridge/src/main/java/com/advergic/reactnative/AdvergicReactNativePackage.java +25 -0
- package/android/app/build.gradle +144 -0
- package/android/app/libs/advergic-sdk.aar +0 -0
- package/android/app/src/main/AndroidManifest.xml +30 -0
- package/android/app/src/main/java/com/advergic/reactnative/AdvergicReactNativePackage.java +26 -0
- package/android/app/src/main/java/com/facebook/react/viewmanagers/AdvergicBannerViewManagerInterface.java +8 -0
- package/android/libs/advergic-sdk.aar +0 -0
- package/android/settings.gradle +7 -0
- package/index.d.ts +135 -0
- package/index.js +27 -0
- package/install.js +158 -0
- package/ios/AdvergicBannerView.swift +59 -0
- package/ios/AdvergicBannerViewManager.m +18 -0
- package/ios/AdvergicBannerViewManager.swift +24 -0
- package/ios/AdvergicReactNativeModule.m +36 -0
- package/ios/AdvergicReactNativeModule.swift +363 -0
- package/package.json +57 -0
- package/react-native.config.js +18 -0
- package/src/advergic/AdvergicBannerAd.tsx +51 -0
- package/src/advergic/AdvergicSDK.ts +318 -0
- package/src/advergic/index.ts +11 -0
- package/src/advergic/types.ts +23 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface SDKInitializedEvent {
|
|
5
|
+
initialized: boolean;
|
|
6
|
+
adUnitCount?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface BotDetectionEvent {
|
|
10
|
+
passed: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AdUnitEvent {
|
|
14
|
+
adUnitId: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AdUnitErrorEvent extends AdUnitEvent {
|
|
18
|
+
error: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BannerAdLoadedEvent {
|
|
22
|
+
adUnitId: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AdError {
|
|
26
|
+
adUnitId: string;
|
|
27
|
+
error: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NativeAdData {
|
|
31
|
+
title: string;
|
|
32
|
+
body: string;
|
|
33
|
+
callToAction: string;
|
|
34
|
+
mainImage: string;
|
|
35
|
+
icon: string;
|
|
36
|
+
sponsoredBy: string;
|
|
37
|
+
advertiserDomain: string;
|
|
38
|
+
clickUrl: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AdvergicConfig {
|
|
42
|
+
apiKey: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type AdFormat =
|
|
46
|
+
| "banner"
|
|
47
|
+
| "interstitial"
|
|
48
|
+
| "rewarded"
|
|
49
|
+
| "native"
|
|
50
|
+
| "appopen";
|
|
51
|
+
|
|
52
|
+
export interface AdvergicBannerAdProps {
|
|
53
|
+
adUnitId: string;
|
|
54
|
+
style?: ViewStyle;
|
|
55
|
+
onAdLoaded?: () => void;
|
|
56
|
+
onAdFailedToLoad?: (error: string) => void;
|
|
57
|
+
onAdClicked?: () => void;
|
|
58
|
+
onAdImpression?: () => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface AdvergicInterface {
|
|
62
|
+
initialize: (apiKey: string) => Promise<boolean>;
|
|
63
|
+
canServeAds: () => Promise<boolean>;
|
|
64
|
+
getAdUnits: () => Promise<Array<{ id: string; name: string; type: string }>>;
|
|
65
|
+
performFollowUpBotDetection: () => void;
|
|
66
|
+
|
|
67
|
+
showBannerAd: (adUnitId: string, containerId?: number) => void;
|
|
68
|
+
showInterstitialAd: (adUnitId: string) => void;
|
|
69
|
+
showRewardedAd: (adUnitId: string) => void;
|
|
70
|
+
showAppOpenAd: (adUnitId: string) => void;
|
|
71
|
+
showNativeAd: (adUnitId: string, containerId?: number) => void;
|
|
72
|
+
loadNativeAd: (adUnitId: string) => Promise<NativeAdData>;
|
|
73
|
+
|
|
74
|
+
addListener: <K extends string>(
|
|
75
|
+
event: K,
|
|
76
|
+
callback: (event: any) => void,
|
|
77
|
+
) => any;
|
|
78
|
+
removeAllListeners: () => void;
|
|
79
|
+
|
|
80
|
+
onSDKInitialized: (callback: (event: SDKInitializedEvent) => void) => any;
|
|
81
|
+
onBotDetectionResult: (callback: (event: BotDetectionEvent) => void) => any;
|
|
82
|
+
|
|
83
|
+
onBannerAdLoaded: (callback: (event: AdUnitEvent) => void) => any;
|
|
84
|
+
onBannerAdFailedToLoad: (callback: (event: AdUnitErrorEvent) => void) => any;
|
|
85
|
+
onBannerAdClicked: (callback: (event: AdUnitEvent) => void) => any;
|
|
86
|
+
onBannerAdImpression: (callback: (event: AdUnitEvent) => void) => any;
|
|
87
|
+
|
|
88
|
+
onInterstitialAdLoaded: (callback: (event: AdUnitEvent) => void) => any;
|
|
89
|
+
onInterstitialAdFailedToLoad: (
|
|
90
|
+
callback: (event: AdUnitErrorEvent) => void,
|
|
91
|
+
) => any;
|
|
92
|
+
onInterstitialAdShowed: (callback: (event: AdUnitEvent) => void) => any;
|
|
93
|
+
onInterstitialAdDismissed: (callback: (event: AdUnitEvent) => void) => any;
|
|
94
|
+
onInterstitialAdFailedToShow: (
|
|
95
|
+
callback: (event: AdUnitErrorEvent) => void,
|
|
96
|
+
) => any;
|
|
97
|
+
onInterstitialAdClicked: (callback: (event: AdUnitEvent) => void) => any;
|
|
98
|
+
onInterstitialAdImpression: (callback: (event: AdUnitEvent) => void) => any;
|
|
99
|
+
|
|
100
|
+
onRewardedAdLoaded: (callback: (event: AdUnitEvent) => void) => any;
|
|
101
|
+
onRewardedAdFailedToLoad: (
|
|
102
|
+
callback: (event: AdUnitErrorEvent) => void,
|
|
103
|
+
) => any;
|
|
104
|
+
onRewardedAdShowed: (callback: (event: AdUnitEvent) => void) => any;
|
|
105
|
+
onRewardedAdFailedToShow: (
|
|
106
|
+
callback: (event: AdUnitErrorEvent) => void,
|
|
107
|
+
) => any;
|
|
108
|
+
onRewardedAdOpened: (callback: (event: AdUnitEvent) => void) => any;
|
|
109
|
+
onRewardedAdClicked: (callback: (event: AdUnitEvent) => void) => any;
|
|
110
|
+
onRewardedAdClosed: (callback: (event: AdUnitEvent) => void) => any;
|
|
111
|
+
onRewardedAdUserEarnedReward: (
|
|
112
|
+
callback: (reward: { type: string; amount: number }) => void,
|
|
113
|
+
) => any;
|
|
114
|
+
|
|
115
|
+
onAppOpenAdLoaded: (callback: (event: AdUnitEvent) => void) => any;
|
|
116
|
+
onAppOpenAdFailedToLoad: (callback: (event: AdUnitErrorEvent) => void) => any;
|
|
117
|
+
onAppOpenAdShowed: (callback: (event: AdUnitEvent) => void) => any;
|
|
118
|
+
onAppOpenAdDismissed: (callback: (event: AdUnitEvent) => void) => any;
|
|
119
|
+
onAppOpenAdFailedToShow: (callback: (event: AdUnitErrorEvent) => void) => any;
|
|
120
|
+
onAppOpenAdClicked: (callback: (event: AdUnitEvent) => void) => any;
|
|
121
|
+
onAppOpenAdImpression: (callback: (event: AdUnitEvent) => void) => any;
|
|
122
|
+
|
|
123
|
+
onNativeAdLoaded: (callback: (event: AdUnitEvent) => void) => any;
|
|
124
|
+
onNativeAdFailedToLoad: (callback: (event: AdUnitErrorEvent) => void) => any;
|
|
125
|
+
onNativeAdClicked: (callback: (event: AdUnitEvent) => void) => any;
|
|
126
|
+
onNativeAdImpression: (callback: (event: AdUnitEvent) => void) => any;
|
|
127
|
+
onNativePrebidAdNotFound: (callback: (event: AdUnitEvent) => void) => any;
|
|
128
|
+
onNativePrebidAdNotValid: (callback: (event: AdUnitEvent) => void) => any;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare const Advergic: AdvergicInterface;
|
|
132
|
+
export default Advergic;
|
|
133
|
+
export type { AdvergicInterface };
|
|
134
|
+
|
|
135
|
+
export declare const AdvergicBannerAd: React.FC<AdvergicBannerAdProps>;
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdvergicInterface,
|
|
3
|
+
SDKInitializedEvent,
|
|
4
|
+
BotDetectionEvent,
|
|
5
|
+
AdUnitEvent,
|
|
6
|
+
AdUnitErrorEvent,
|
|
7
|
+
AdvergicConfig,
|
|
8
|
+
AdvergicBannerAdProps,
|
|
9
|
+
NativeAdData,
|
|
10
|
+
} from './index.d';
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
AdvergicInterface,
|
|
14
|
+
SDKInitializedEvent,
|
|
15
|
+
BotDetectionEvent,
|
|
16
|
+
AdUnitEvent,
|
|
17
|
+
AdUnitErrorEvent,
|
|
18
|
+
AdvergicConfig,
|
|
19
|
+
AdvergicBannerAdProps,
|
|
20
|
+
NativeAdData,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
import Advergic from './src/advergic/AdvergicSDK';
|
|
24
|
+
import { AdvergicBannerAd } from './src/advergic/AdvergicBannerAd';
|
|
25
|
+
|
|
26
|
+
export default Advergic;
|
|
27
|
+
export { AdvergicBannerAd };
|
package/install.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* advergic-react-native post-install script
|
|
4
|
+
* Minimal setup - React Native auto-linking handles most configuration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
const PACKAGE_ROOT = __dirname;
|
|
11
|
+
const AAR_SOURCE = path.join(PACKAGE_ROOT, "android", "libs", "advergic-sdk.aar");
|
|
12
|
+
const PROJECT_ROOT = path.resolve(PACKAGE_ROOT, "..", "..");
|
|
13
|
+
|
|
14
|
+
const checkReactNativeVersion = () => {
|
|
15
|
+
try {
|
|
16
|
+
const rnPkgPath = path.join(PROJECT_ROOT, "node_modules", "react-native", "package.json");
|
|
17
|
+
if (!fs.existsSync(rnPkgPath)) {
|
|
18
|
+
console.warn("[Advergic] React Native not found. Installing it first?");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const rnPkg = require(rnPkgPath);
|
|
22
|
+
const version = rnPkg.version;
|
|
23
|
+
const major = parseInt(rnPkg.version.split(".")[0]);
|
|
24
|
+
|
|
25
|
+
if (major < 76) {
|
|
26
|
+
console.warn(
|
|
27
|
+
`[Advergic] Warning: React Native ${version} detected. This package requires RN 0.76+.`,
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
console.log(`[Advergic] ✓ React Native ${version} detected`);
|
|
31
|
+
}
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// React Native might not be installed yet during initial setup
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const verifyAAR = () => {
|
|
38
|
+
if (!fs.existsSync(AAR_SOURCE)) {
|
|
39
|
+
console.error("");
|
|
40
|
+
console.error("[Advergic] ERROR: advergic-sdk.aar not found!");
|
|
41
|
+
console.error(`[Advergic] Expected at: ${AAR_SOURCE}`);
|
|
42
|
+
console.error("[Advergic]");
|
|
43
|
+
console.error("[Advergic] The AAR file must be included in the npm package.");
|
|
44
|
+
console.error("[Advergic] If you're building from source, run:");
|
|
45
|
+
console.error("[Advergic] cd android-sdk");
|
|
46
|
+
console.error("[Advergic] ./gradlew :advergic-sdk:assembleRelease");
|
|
47
|
+
console.error("[Advergic] cp advergic-sdk/build/outputs/aar/advergic-sdk-release.aar ../advergic-react-native/android/libs/");
|
|
48
|
+
console.error("");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
console.log("[Advergic] ✓ advergic-sdk.aar found");
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const copyAARToNodeModules = () => {
|
|
55
|
+
// Copy AAR to bridge module libs for auto-linking
|
|
56
|
+
const bridgeLibsDir = path.join(PACKAGE_ROOT, "android", "advergic-bridge", "libs");
|
|
57
|
+
if (!fs.existsSync(bridgeLibsDir)) {
|
|
58
|
+
fs.mkdirSync(bridgeLibsDir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const AAR_DEST = path.join(bridgeLibsDir, "advergic-sdk.aar");
|
|
62
|
+
if (!fs.existsSync(AAR_DEST)) {
|
|
63
|
+
fs.copyFileSync(AAR_SOURCE, AAR_DEST);
|
|
64
|
+
console.log("[Advergic] ✓ Copied AAR to bridge module");
|
|
65
|
+
} else {
|
|
66
|
+
console.log("[Advergic] ✓ AAR already in bridge module");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Always copy to app/libs for fallback access (create directory if needed)
|
|
70
|
+
const appLibsDir = path.join(PROJECT_ROOT, "android", "app", "libs");
|
|
71
|
+
if (fs.existsSync(path.join(PROJECT_ROOT, "android", "app"))) {
|
|
72
|
+
if (!fs.existsSync(appLibsDir)) {
|
|
73
|
+
fs.mkdirSync(appLibsDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
const AAR_APP_DEST = path.join(appLibsDir, "advergic-sdk.aar");
|
|
76
|
+
if (!fs.existsSync(AAR_APP_DEST)) {
|
|
77
|
+
fs.copyFileSync(AAR_SOURCE, AAR_APP_DEST);
|
|
78
|
+
console.log("[Advergic] ✓ Copied AAR to app/libs");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const ensureAppBuildGradleRepositories = () => {
|
|
84
|
+
const appBuildGradlePath = path.join(PROJECT_ROOT, "android", "app", "build.gradle");
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(appBuildGradlePath)) {
|
|
87
|
+
return; // App not set up yet
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let content = fs.readFileSync(appBuildGradlePath, "utf8");
|
|
91
|
+
|
|
92
|
+
// Check if repositories block already exists
|
|
93
|
+
if (content.includes("repositories {")) {
|
|
94
|
+
console.log("[Advergic] ✓ app/build.gradle repositories already configured");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Add repositories block before dependencies
|
|
99
|
+
const repositoriesBlock = `
|
|
100
|
+
repositories {
|
|
101
|
+
flatDir {
|
|
102
|
+
dirs file("${projectDir}/libs")
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
// Insert before the first "dependencies" block
|
|
108
|
+
if (content.includes("dependencies {")) {
|
|
109
|
+
content = content.replace("dependencies {", repositoriesBlock + "\ndependencies {");
|
|
110
|
+
fs.writeFileSync(appBuildGradlePath, content, "utf8");
|
|
111
|
+
console.log("[Advergic] ✓ Added repositories configuration to app/build.gradle");
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const printSetupComplete = () => {
|
|
116
|
+
console.log("");
|
|
117
|
+
console.log("╔════════════════════════════════════════════════════════════════╗");
|
|
118
|
+
console.log("║ Advergic SDK Setup Complete! ║");
|
|
119
|
+
console.log("╚════════════════════════════════════════════════════════════════╝");
|
|
120
|
+
console.log("");
|
|
121
|
+
console.log("✓ React Native auto-linking will handle the module integration");
|
|
122
|
+
console.log("✓ AAR files are automatically set up");
|
|
123
|
+
console.log("");
|
|
124
|
+
console.log("Next step - Add to AndroidManifest.xml:");
|
|
125
|
+
console.log("");
|
|
126
|
+
console.log(' <application>');
|
|
127
|
+
console.log(' <meta-data');
|
|
128
|
+
console.log(' android:name="com.google.android.gms.ads.APPLICATION_ID"');
|
|
129
|
+
console.log(' android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />');
|
|
130
|
+
console.log(' <!-- Replace with YOUR Google Ads Application ID -->');
|
|
131
|
+
console.log(" </application>");
|
|
132
|
+
console.log("");
|
|
133
|
+
console.log("Get your Application ID from:");
|
|
134
|
+
console.log(" https://admob.google.com/");
|
|
135
|
+
console.log("");
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const setup = () => {
|
|
139
|
+
console.log("");
|
|
140
|
+
console.log("[Advergic] Starting post-install setup...");
|
|
141
|
+
|
|
142
|
+
checkReactNativeVersion();
|
|
143
|
+
verifyAAR();
|
|
144
|
+
copyAARToNodeModules();
|
|
145
|
+
ensureAppBuildGradleRepositories();
|
|
146
|
+
printSetupComplete();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (require.main === module) {
|
|
150
|
+
try {
|
|
151
|
+
setup();
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error("[Advergic] Post-install failed:", error.message);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = { setup };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AdvergicBannerView.swift
|
|
3
|
+
// AdvergicReactNative
|
|
4
|
+
//
|
|
5
|
+
// Native view backing the `AdvergicBannerAd` React component. The view itself
|
|
6
|
+
// is the container the iOS SDK renders the banner into. It auto-loads as soon
|
|
7
|
+
// as `adUnitId` is set, mirroring the Android `AdvergicBannerContainerView`.
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
import UIKit
|
|
11
|
+
import React
|
|
12
|
+
|
|
13
|
+
class AdvergicBannerView: UIView {
|
|
14
|
+
|
|
15
|
+
@objc var onAdLoaded: RCTBubblingEventBlock?
|
|
16
|
+
@objc var onAdFailedToLoad: RCTBubblingEventBlock?
|
|
17
|
+
@objc var onAdClicked: RCTBubblingEventBlock?
|
|
18
|
+
@objc var onAdImpression: RCTBubblingEventBlock?
|
|
19
|
+
|
|
20
|
+
private var hasLoadedAd = false
|
|
21
|
+
|
|
22
|
+
@objc var adUnitId: NSString? {
|
|
23
|
+
didSet {
|
|
24
|
+
if let id = adUnitId as String?, !id.isEmpty, !hasLoadedAd {
|
|
25
|
+
loadAd()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private func loadAd() {
|
|
31
|
+
guard let adUnitId = adUnitId as String?, !adUnitId.isEmpty else { return }
|
|
32
|
+
guard let module = AdvergicReactNativeModule.shared else {
|
|
33
|
+
onAdFailedToLoad?(["error": "AdvergicSDK native module not available"])
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
hasLoadedAd = true
|
|
38
|
+
module.loadBanner(
|
|
39
|
+
adUnitId: adUnitId,
|
|
40
|
+
container: self,
|
|
41
|
+
onLoaded: { [weak self] in
|
|
42
|
+
self?.onAdLoaded?([:])
|
|
43
|
+
},
|
|
44
|
+
onFailed: { [weak self] error in
|
|
45
|
+
self?.onAdFailedToLoad?(["error": error])
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Called by the module when the SDK reports a click / impression via its
|
|
51
|
+
// shared delegate (these are not delivered through the banner completion).
|
|
52
|
+
func dispatchClicked() {
|
|
53
|
+
onAdClicked?([:])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func dispatchImpression() {
|
|
57
|
+
onAdImpression?([:])
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AdvergicBannerViewManager.m
|
|
3
|
+
// AdvergicReactNative
|
|
4
|
+
//
|
|
5
|
+
// Exposes the banner view manager and its props / events to React Native.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTViewManager.h>
|
|
9
|
+
|
|
10
|
+
@interface RCT_EXTERN_MODULE(AdvergicBannerViewManager, RCTViewManager)
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_VIEW_PROPERTY(adUnitId, NSString)
|
|
13
|
+
RCT_EXPORT_VIEW_PROPERTY(onAdLoaded, RCTBubblingEventBlock)
|
|
14
|
+
RCT_EXPORT_VIEW_PROPERTY(onAdFailedToLoad, RCTBubblingEventBlock)
|
|
15
|
+
RCT_EXPORT_VIEW_PROPERTY(onAdClicked, RCTBubblingEventBlock)
|
|
16
|
+
RCT_EXPORT_VIEW_PROPERTY(onAdImpression, RCTBubblingEventBlock)
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AdvergicBannerViewManager.swift
|
|
3
|
+
// AdvergicReactNative
|
|
4
|
+
//
|
|
5
|
+
// Registers the `AdvergicBannerView` native component (the "Manager" suffix is
|
|
6
|
+
// stripped by React Native, yielding the component name `AdvergicBannerView`
|
|
7
|
+
// used by `requireNativeComponent` on the JS side).
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
import Foundation
|
|
11
|
+
import React
|
|
12
|
+
|
|
13
|
+
@objc(AdvergicBannerViewManager)
|
|
14
|
+
class AdvergicBannerViewManager: RCTViewManager {
|
|
15
|
+
|
|
16
|
+
override func view() -> UIView! {
|
|
17
|
+
return AdvergicBannerView()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc
|
|
21
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AdvergicReactNativeModule.m
|
|
3
|
+
// AdvergicReactNative
|
|
4
|
+
//
|
|
5
|
+
// Exposes the Swift `AdvergicReactNativeModule` (registered as `AdvergicSDK`)
|
|
6
|
+
// and its methods to the React Native bridge.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <React/RCTBridgeModule.h>
|
|
10
|
+
#import <React/RCTEventEmitter.h>
|
|
11
|
+
|
|
12
|
+
@interface RCT_EXTERN_MODULE(AdvergicSDK, RCTEventEmitter)
|
|
13
|
+
|
|
14
|
+
RCT_EXTERN_METHOD(initialize:(NSString *)apiKey
|
|
15
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
16
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(canServeAds:(RCTPromiseResolveBlock)resolve
|
|
19
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
20
|
+
|
|
21
|
+
RCT_EXTERN_METHOD(getAdUnits:(RCTPromiseResolveBlock)resolve
|
|
22
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
23
|
+
|
|
24
|
+
RCT_EXTERN_METHOD(performFollowUpBotDetection)
|
|
25
|
+
|
|
26
|
+
RCT_EXTERN_METHOD(showBannerAd:(NSString *)adUnitId containerId:(nonnull NSNumber *)containerId)
|
|
27
|
+
|
|
28
|
+
RCT_EXTERN_METHOD(showInterstitialAd:(NSString *)adUnitId)
|
|
29
|
+
|
|
30
|
+
RCT_EXTERN_METHOD(showRewardedAd:(NSString *)adUnitId)
|
|
31
|
+
|
|
32
|
+
RCT_EXTERN_METHOD(showAppOpenAd:(NSString *)adUnitId)
|
|
33
|
+
|
|
34
|
+
RCT_EXTERN_METHOD(showNativeAd:(NSString *)adUnitId containerId:(nonnull NSNumber *)containerId)
|
|
35
|
+
|
|
36
|
+
@end
|