@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
package/Adgeist.podspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "Adgeist"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/the-alter-office/react-native-adgeist.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
s.dependency "AdgeistKit", '= 0.0.1'
|
|
20
|
+
|
|
21
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
23
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
else
|
|
26
|
+
s.dependency "React-Core"
|
|
27
|
+
end
|
|
28
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kishore
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# @thealteroffice/react-native-adgeist
|
|
6
|
+
|
|
7
|
+
A React Native library that allows publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.
|
|
8
|
+
Written in Kotlin, Swift and Typescript. It supports both the Old and New React Native architecture.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
### React Native Bare
|
|
13
|
+
|
|
14
|
+
You can install the package via npm or yarn:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @thealteroffice/react-native-adgeist
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
yarn add @thealteroffice/react-native-adgeist
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Don't forget to run pod-install.
|
|
25
|
+
|
|
26
|
+
### Expo
|
|
27
|
+
|
|
28
|
+
You can install the package like any other Expo package, using the following command:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx expo install @thealteroffice/react-native-adgeist
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Setup
|
|
35
|
+
|
|
36
|
+
### Expo
|
|
37
|
+
|
|
38
|
+
Simply add the library plugin to your `app.json` file:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"expo": {
|
|
43
|
+
"plugins": ["@thealteroffice/react-native-adgeist"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This way, Expo will handle the native setup for you during `prebuild`.
|
|
49
|
+
|
|
50
|
+
> Note: only SDK 50 and above are supported, the plugin is configured to handle only the kotlin template.
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import { BannerAd } from '@thealteroffice/react-native-adgeist';
|
|
56
|
+
|
|
57
|
+
// ...
|
|
58
|
+
|
|
59
|
+
<BannerAd
|
|
60
|
+
dataPublisherId={PUBLISHER_ID}
|
|
61
|
+
dataAdSlot={ADSPACE_ID}
|
|
62
|
+
width={400}
|
|
63
|
+
height={300}
|
|
64
|
+
/>;
|
|
65
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Adgeist_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Adgeist_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def supportsNamespace() {
|
|
29
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
30
|
+
def major = parsed[0].toInteger()
|
|
31
|
+
def minor = parsed[1].toInteger()
|
|
32
|
+
|
|
33
|
+
// Namespace support was added in 7.3.0
|
|
34
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
android {
|
|
38
|
+
if (supportsNamespace()) {
|
|
39
|
+
namespace "com.adgeist"
|
|
40
|
+
|
|
41
|
+
sourceSets {
|
|
42
|
+
main {
|
|
43
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
49
|
+
|
|
50
|
+
defaultConfig {
|
|
51
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
52
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
buildFeatures {
|
|
56
|
+
buildConfig true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
buildTypes {
|
|
60
|
+
release {
|
|
61
|
+
minifyEnabled false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
lintOptions {
|
|
66
|
+
disable "GradleCompatible"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
compileOptions {
|
|
70
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
71
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
sourceSets {
|
|
75
|
+
main {
|
|
76
|
+
java.srcDirs += [
|
|
77
|
+
"generated/java",
|
|
78
|
+
"generated/jni"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
repositories {
|
|
85
|
+
mavenCentral()
|
|
86
|
+
google()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
90
|
+
|
|
91
|
+
dependencies {
|
|
92
|
+
implementation "com.facebook.react:react-android"
|
|
93
|
+
implementation "ai.adgeist:adgeistkit:0.0.1"
|
|
94
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
react {
|
|
98
|
+
jsRootDir = file("../src/")
|
|
99
|
+
libraryName = "Adgeist"
|
|
100
|
+
codegenJavaPackageName = "com.adgeist"
|
|
101
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.adgeist;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
21
|
+
import javax.annotation.Nonnull;
|
|
22
|
+
|
|
23
|
+
public abstract class NativeAdgeistSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
24
|
+
public static final String NAME = "Adgeist";
|
|
25
|
+
|
|
26
|
+
public NativeAdgeistSpec(ReactApplicationContext reactContext) {
|
|
27
|
+
super(reactContext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public @Nonnull String getName() {
|
|
32
|
+
return NAME;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
public abstract void fetchCreative(String adSpaceId, String publisherId, Promise promise);
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
@DoNotStrip
|
|
41
|
+
public abstract void sendCreativeAnalytic(String campaignId, String adSpaceId, String publisherId, String eventType, Promise promise);
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNAdgeistSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNAdgeistSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNAdgeistSpec PUBLIC . react/renderer/components/RNAdgeistSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNAdgeistSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_RNAdgeistSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNAdgeistSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeAdgeistSpecJSI_fetchCreative(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "fetchCreative", "(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeAdgeistSpecJSI_sendCreativeAnalytic(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "sendCreativeAnalytic", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeAdgeistSpecJSI::NativeAdgeistSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
26
|
+
: JavaTurboModule(params) {
|
|
27
|
+
methodMap_["fetchCreative"] = MethodMetadata {2, __hostFunction_NativeAdgeistSpecJSI_fetchCreative};
|
|
28
|
+
methodMap_["sendCreativeAnalytic"] = MethodMetadata {4, __hostFunction_NativeAdgeistSpecJSI_sendCreativeAnalytic};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<TurboModule> RNAdgeistSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
32
|
+
if (moduleName == "Adgeist") {
|
|
33
|
+
return std::make_shared<NativeAdgeistSpecJSI>(params);
|
|
34
|
+
}
|
|
35
|
+
return nullptr;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeAdgeist'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeAdgeistSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeAdgeistSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNAdgeistSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNAdgeistSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeAdgeistCxxSpecJSI_fetchCreative(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeAdgeistCxxSpecJSI *>(&turboModule)->fetchCreative(
|
|
16
|
+
rt,
|
|
17
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
18
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
static jsi::Value __hostFunction_NativeAdgeistCxxSpecJSI_sendCreativeAnalytic(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
+
return static_cast<NativeAdgeistCxxSpecJSI *>(&turboModule)->sendCreativeAnalytic(
|
|
23
|
+
rt,
|
|
24
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
25
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
26
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt),
|
|
27
|
+
count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asString(rt)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
NativeAdgeistCxxSpecJSI::NativeAdgeistCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
32
|
+
: TurboModule("Adgeist", jsInvoker) {
|
|
33
|
+
methodMap_["fetchCreative"] = MethodMetadata {2, __hostFunction_NativeAdgeistCxxSpecJSI_fetchCreative};
|
|
34
|
+
methodMap_["sendCreativeAnalytic"] = MethodMetadata {4, __hostFunction_NativeAdgeistCxxSpecJSI_sendCreativeAnalytic};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeAdgeistCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeAdgeistCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Value fetchCreative(jsi::Runtime &rt, jsi::String adSpaceId, jsi::String publisherId) = 0;
|
|
24
|
+
virtual jsi::Value sendCreativeAnalytic(jsi::Runtime &rt, jsi::String campaignId, jsi::String adSpaceId, jsi::String publisherId, jsi::String eventType) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
class JSI_EXPORT NativeAdgeistCxxSpec : public TurboModule {
|
|
30
|
+
public:
|
|
31
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.create(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
36
|
+
return delegate_.getPropertyNames(runtime);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static constexpr std::string_view kModuleName = "Adgeist";
|
|
40
|
+
|
|
41
|
+
protected:
|
|
42
|
+
NativeAdgeistCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
43
|
+
: TurboModule(std::string{NativeAdgeistCxxSpec::kModuleName}, jsInvoker),
|
|
44
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
class Delegate : public NativeAdgeistCxxSpecJSI {
|
|
49
|
+
public:
|
|
50
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
51
|
+
NativeAdgeistCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
jsi::Value fetchCreative(jsi::Runtime &rt, jsi::String adSpaceId, jsi::String publisherId) override {
|
|
56
|
+
static_assert(
|
|
57
|
+
bridging::getParameterCount(&T::fetchCreative) == 3,
|
|
58
|
+
"Expected fetchCreative(...) to have 3 parameters");
|
|
59
|
+
|
|
60
|
+
return bridging::callFromJs<jsi::Value>(
|
|
61
|
+
rt, &T::fetchCreative, jsInvoker_, instance_, std::move(adSpaceId), std::move(publisherId));
|
|
62
|
+
}
|
|
63
|
+
jsi::Value sendCreativeAnalytic(jsi::Runtime &rt, jsi::String campaignId, jsi::String adSpaceId, jsi::String publisherId, jsi::String eventType) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::sendCreativeAnalytic) == 5,
|
|
66
|
+
"Expected sendCreativeAnalytic(...) to have 5 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<jsi::Value>(
|
|
69
|
+
rt, &T::sendCreativeAnalytic, jsInvoker_, instance_, std::move(campaignId), std::move(adSpaceId), std::move(publisherId), std::move(eventType));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend class NativeAdgeistCxxSpec;
|
|
74
|
+
T *instance_;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Delegate delegate_;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.adgeist
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.WritableMap
|
|
10
|
+
import com.adgeistkit.AdgeistCore
|
|
11
|
+
import com.adgeistkit.CreativeDataModel
|
|
12
|
+
import com.adgeistkit.Campaign
|
|
13
|
+
import com.adgeistkit.Creative
|
|
14
|
+
import com.adgeistkit.BudgetSettings
|
|
15
|
+
|
|
16
|
+
@ReactModule(name = AdgeistModule.NAME)
|
|
17
|
+
class AdgeistModule(reactContext: ReactApplicationContext) :
|
|
18
|
+
NativeAdgeistSpec(reactContext), TurboModule {
|
|
19
|
+
|
|
20
|
+
private val adgeistInstanceFromLibrary = AdgeistCore.initialize(reactContext.applicationContext)
|
|
21
|
+
private val getAd = adgeistInstanceFromLibrary.getCreative()
|
|
22
|
+
private val postCreativeAnalytic = adgeistInstanceFromLibrary.postCreativeAnalytics()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
override fun getName(): String {
|
|
26
|
+
return NAME
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun fetchCreative(adSpaceId: String, publisherId: String, promise: Promise) {
|
|
30
|
+
getAd.fetchCreative(adSpaceId, publisherId) { adData ->
|
|
31
|
+
if (adData != null) {
|
|
32
|
+
promise.resolve(adData.toWritableMap())
|
|
33
|
+
} else {
|
|
34
|
+
promise.reject("NO_AD", "Ad data not available")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun sendCreativeAnalytic(campaignId: String, adSpaceId: String, publisherId: String, eventType: String, promise: Promise) {
|
|
40
|
+
postCreativeAnalytic.sendTrackingData(campaignId, adSpaceId, publisherId, eventType) { adData ->
|
|
41
|
+
if (adData != null) {
|
|
42
|
+
Log.d("MyActivity of app module", adData)
|
|
43
|
+
promise.resolve(adData)
|
|
44
|
+
} else {
|
|
45
|
+
promise.reject("NO_AD", "Couldn't find the campaign to update analytics")
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
companion object {
|
|
51
|
+
const val NAME = "Adgeist"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Extension function to convert CreativeData to WritableMap
|
|
56
|
+
fun CreativeDataModel.toWritableMap(): WritableMap {
|
|
57
|
+
val map = Arguments.createMap()
|
|
58
|
+
map.putBoolean("success", success)
|
|
59
|
+
map.putString("message", message)
|
|
60
|
+
|
|
61
|
+
val dataMap = Arguments.createMap()
|
|
62
|
+
data?.let { campaign ->
|
|
63
|
+
dataMap.putString("_id", campaign._id)
|
|
64
|
+
dataMap.putString("name", campaign.name)
|
|
65
|
+
|
|
66
|
+
val creativeMap = Arguments.createMap()
|
|
67
|
+
campaign.creative?.let { creative ->
|
|
68
|
+
creativeMap.putString("title", creative.title)
|
|
69
|
+
creativeMap.putString("description", creative.description)
|
|
70
|
+
creativeMap.putString("fileUrl", creative.fileUrl)
|
|
71
|
+
creativeMap.putString("ctaUrl", creative.ctaUrl)
|
|
72
|
+
creativeMap.putString("type", creative.type)
|
|
73
|
+
creativeMap.putString("fileName", creative.fileName)
|
|
74
|
+
creativeMap.putString("createdAt", creative.createdAt)
|
|
75
|
+
creativeMap.putString("updatedAt", creative.updatedAt)
|
|
76
|
+
}
|
|
77
|
+
dataMap.putMap("creative", creativeMap)
|
|
78
|
+
|
|
79
|
+
val budgetMap = Arguments.createMap()
|
|
80
|
+
campaign.budgetSettings?.let { budget ->
|
|
81
|
+
budgetMap.putDouble("totalBudget", budget.totalBudget)
|
|
82
|
+
budgetMap.putDouble("spentBudget", budget.spentBudget)
|
|
83
|
+
}
|
|
84
|
+
dataMap.putMap("budgetSettings", budgetMap)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
map.putMap("data", dataMap)
|
|
88
|
+
return map
|
|
89
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.adgeist
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class AdgeistPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == AdgeistModule.NAME) {
|
|
13
|
+
AdgeistModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[AdgeistModule.NAME] = ReactModuleInfo(
|
|
23
|
+
AdgeistModule.NAME,
|
|
24
|
+
AdgeistModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/ios/Adgeist.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import "generated/RNAdgeistSpec/RNAdgeistSpec.h"
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
@interface Adgeist : NSObject <NativeAdgeistSpec>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_END
|
|
11
|
+
|
|
12
|
+
#else
|
|
13
|
+
#import <React/RCTBridgeModule.h>
|
|
14
|
+
|
|
15
|
+
@interface Adgeist : NSObject <RCTBridgeModule>
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
@end
|