react-native-liftoffads 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/LICENSE +20 -0
- package/NitroLiftoffAds.podspec +26 -0
- package/README.md +61 -0
- package/android/CMakeLists.txt +20 -0
- package/android/build.gradle +132 -0
- package/android/consumer-rules.pro +2 -0
- package/android/fix-prefab.gradle +46 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffAds.kt +121 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffInterstitialAd.kt +96 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffRewardedAd.kt +104 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/LiftoffAdEventEmitter.kt +51 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/LiftoffAndroidUtils.kt +54 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/NitroLiftoffAdsPackage.java +27 -0
- package/ios/HybridLiftoffAds.swift +113 -0
- package/ios/HybridLiftoffInterstitialAd.swift +98 -0
- package/ios/HybridLiftoffRewardedAd.swift +100 -0
- package/ios/LiftoffSupport.swift +106 -0
- package/lib/module/index.js +169 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.test.js +205 -0
- package/lib/module/index.test.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/LiftoffAds.nitro.js +4 -0
- package/lib/module/specs/LiftoffAds.nitro.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +72 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.test.d.ts +2 -0
- package/lib/typescript/src/index.test.d.ts.map +1 -0
- package/lib/typescript/src/specs/LiftoffAds.nitro.d.ts +46 -0
- package/lib/typescript/src/specs/LiftoffAds.nitro.d.ts.map +1 -0
- package/nitro.json +18 -0
- package/nitrogen/generated/android/NitroLiftoffAds+autolinking.cmake +85 -0
- package/nitrogen/generated/android/NitroLiftoffAds+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroLiftoffAdsOnLoad.cpp +50 -0
- package/nitrogen/generated/android/NitroLiftoffAdsOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_LiftoffAdEventPayload_.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffAdsSpec.cpp +88 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffAdsSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffInterstitialAdSpec.cpp +89 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffInterstitialAdSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffRewardedAdSpec.cpp +93 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffRewardedAdSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JLiftoffAdEventPayload.hpp +58 -0
- package/nitrogen/generated/android/c++/JLiftoffAdEventType.hpp +77 -0
- package/nitrogen/generated/android/c++/JLiftoffAdShowOptions.hpp +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/Func_void_std__optional_LiftoffAdEventPayload_.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffAdsSpec.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffInterstitialAdSpec.kt +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffRewardedAdSpec.kt +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdEventPayload.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdEventType.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdShowOptions.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/NitroLiftoffAdsOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroLiftoffAds+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Bridge.cpp +90 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Bridge.hpp +285 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Umbrella.hpp +66 -0
- package/nitrogen/generated/ios/NitroLiftoffAdsAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroLiftoffAdsAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffAdsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffAdsSpecSwift.hpp +114 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffInterstitialAdSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffInterstitialAdSpecSwift.hpp +110 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffRewardedAdSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffRewardedAdSpecSwift.hpp +116 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_LiftoffAdEventPayload_.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffAdsSpec.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffAdsSpec_cxx.swift +193 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffInterstitialAdSpec.swift +53 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffInterstitialAdSpec_cxx.swift +193 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffRewardedAdSpec.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffRewardedAdSpec_cxx.swift +204 -0
- package/nitrogen/generated/ios/swift/LiftoffAdEventPayload.swift +77 -0
- package/nitrogen/generated/ios/swift/LiftoffAdEventType.swift +64 -0
- package/nitrogen/generated/ios/swift/LiftoffAdShowOptions.swift +47 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffAdsSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffAdsSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffInterstitialAdSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffInterstitialAdSpec.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffRewardedAdSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffRewardedAdSpec.hpp +78 -0
- package/nitrogen/generated/shared/c++/LiftoffAdEventPayload.hpp +72 -0
- package/nitrogen/generated/shared/c++/LiftoffAdEventType.hpp +100 -0
- package/nitrogen/generated/shared/c++/LiftoffAdShowOptions.hpp +67 -0
- package/package.json +173 -0
- package/react-native.config.js +8 -0
- package/src/index.test.ts +257 -0
- package/src/index.ts +307 -0
- package/src/specs/LiftoffAds.nitro.ts +67 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroLiftoffAds+autolinking.cmake
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroLiftoffAds+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_NITROLIFTOFFADS_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
NitroLiftoffAds PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/NitroLiftoffAdsOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridLiftoffInterstitialAdSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/HybridLiftoffRewardedAdSpec.cpp
|
|
38
|
+
../nitrogen/generated/shared/c++/HybridLiftoffAdsSpec.cpp
|
|
39
|
+
# Android-specific Nitrogen C++ sources
|
|
40
|
+
../nitrogen/generated/android/c++/JHybridLiftoffInterstitialAdSpec.cpp
|
|
41
|
+
../nitrogen/generated/android/c++/JHybridLiftoffRewardedAdSpec.cpp
|
|
42
|
+
../nitrogen/generated/android/c++/JHybridLiftoffAdsSpec.cpp
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
46
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
47
|
+
target_compile_definitions(
|
|
48
|
+
NitroLiftoffAds PRIVATE
|
|
49
|
+
-DFOLLY_NO_CONFIG=1
|
|
50
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
51
|
+
-DFOLLY_USE_LIBCPP=1
|
|
52
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
53
|
+
-DFOLLY_MOBILE=1
|
|
54
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
55
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
56
|
+
# Once we target android-23 above, we can comment
|
|
57
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
58
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Add all libraries required by the generated specs
|
|
62
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
63
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
64
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
65
|
+
|
|
66
|
+
# Link all libraries together
|
|
67
|
+
target_link_libraries(
|
|
68
|
+
NitroLiftoffAds
|
|
69
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
70
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
71
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
75
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
76
|
+
target_link_libraries(
|
|
77
|
+
NitroLiftoffAds
|
|
78
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
79
|
+
)
|
|
80
|
+
else()
|
|
81
|
+
target_link_libraries(
|
|
82
|
+
NitroLiftoffAds
|
|
83
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
84
|
+
)
|
|
85
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroLiftoffAds+autolinking.gradle
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/NitroLiftoffAds+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 NitroLiftoffAds is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroLiftoffAdsOnLoad.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#ifndef BUILDING_NITROLIFTOFFADS_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error NitroLiftoffAdsOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "NitroLiftoffAdsOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridLiftoffInterstitialAdSpec.hpp"
|
|
19
|
+
#include "JFunc_void_std__optional_LiftoffAdEventPayload_.hpp"
|
|
20
|
+
#include "JHybridLiftoffRewardedAdSpec.hpp"
|
|
21
|
+
#include "JHybridLiftoffAdsSpec.hpp"
|
|
22
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
23
|
+
|
|
24
|
+
namespace margelo::nitro::liftoffads {
|
|
25
|
+
|
|
26
|
+
int initialize(JavaVM* vm) {
|
|
27
|
+
using namespace margelo::nitro;
|
|
28
|
+
using namespace margelo::nitro::liftoffads;
|
|
29
|
+
using namespace facebook;
|
|
30
|
+
|
|
31
|
+
return facebook::jni::initialize(vm, [] {
|
|
32
|
+
// Register native JNI methods
|
|
33
|
+
margelo::nitro::liftoffads::JHybridLiftoffInterstitialAdSpec::registerNatives();
|
|
34
|
+
margelo::nitro::liftoffads::JFunc_void_std__optional_LiftoffAdEventPayload__cxx::registerNatives();
|
|
35
|
+
margelo::nitro::liftoffads::JHybridLiftoffRewardedAdSpec::registerNatives();
|
|
36
|
+
margelo::nitro::liftoffads::JHybridLiftoffAdsSpec::registerNatives();
|
|
37
|
+
|
|
38
|
+
// Register Nitro Hybrid Objects
|
|
39
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
40
|
+
"LiftoffAds",
|
|
41
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
42
|
+
static DefaultConstructableObject<JHybridLiftoffAdsSpec::javaobject> object("com/margelo/nitro/liftoffads/HybridLiftoffAds");
|
|
43
|
+
auto instance = object.create();
|
|
44
|
+
return instance->cthis()->shared();
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroLiftoffAdsOnLoad.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include <jni.h>
|
|
9
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::liftoffads {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of NitroLiftoffAds, and autolinks all Hybrid Objects.
|
|
15
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
|
|
16
|
+
* Example:
|
|
17
|
+
* ```cpp (cpp-adapter.cpp)
|
|
18
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
+
* return margelo::nitro::liftoffads::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_std__optional_LiftoffAdEventPayload_.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include "LiftoffAdEventPayload.hpp"
|
|
14
|
+
#include <optional>
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include "JLiftoffAdEventPayload.hpp"
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::liftoffads {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents the Java/Kotlin callback `(payload: LiftoffAdEventPayload?) -> Unit`.
|
|
25
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
26
|
+
*/
|
|
27
|
+
struct JFunc_void_std__optional_LiftoffAdEventPayload_: public jni::JavaClass<JFunc_void_std__optional_LiftoffAdEventPayload_> {
|
|
28
|
+
public:
|
|
29
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/liftoffads/Func_void_std__optional_LiftoffAdEventPayload_;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Invokes the function this `JFunc_void_std__optional_LiftoffAdEventPayload_` instance holds through JNI.
|
|
34
|
+
*/
|
|
35
|
+
void invoke(const std::optional<LiftoffAdEventPayload>& payload) const {
|
|
36
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JLiftoffAdEventPayload> /* payload */)>("invoke");
|
|
37
|
+
method(self(), payload.has_value() ? JLiftoffAdEventPayload::fromCpp(payload.value()) : nullptr);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An implementation of Func_void_std__optional_LiftoffAdEventPayload_ that is backed by a C++ implementation (using `std::function<...>`)
|
|
43
|
+
*/
|
|
44
|
+
struct JFunc_void_std__optional_LiftoffAdEventPayload__cxx final: public jni::HybridClass<JFunc_void_std__optional_LiftoffAdEventPayload__cxx, JFunc_void_std__optional_LiftoffAdEventPayload_> {
|
|
45
|
+
public:
|
|
46
|
+
static jni::local_ref<JFunc_void_std__optional_LiftoffAdEventPayload_::javaobject> fromCpp(const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& func) {
|
|
47
|
+
return JFunc_void_std__optional_LiftoffAdEventPayload__cxx::newObjectCxxArgs(func);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
/**
|
|
52
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_std__optional_LiftoffAdEventPayload__cxx` instance holds.
|
|
53
|
+
*/
|
|
54
|
+
void invoke_cxx(jni::alias_ref<JLiftoffAdEventPayload> payload) {
|
|
55
|
+
_func(payload != nullptr ? std::make_optional(payload->toCpp()) : std::nullopt);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
[[nodiscard]]
|
|
60
|
+
inline const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& getFunction() const {
|
|
61
|
+
return _func;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/liftoffads/Func_void_std__optional_LiftoffAdEventPayload__cxx;";
|
|
66
|
+
static void registerNatives() {
|
|
67
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__optional_LiftoffAdEventPayload__cxx::invoke_cxx)});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
explicit JFunc_void_std__optional_LiftoffAdEventPayload__cxx(const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& func): _func(func) { }
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
friend HybridBase;
|
|
75
|
+
std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)> _func;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridLiftoffAdsSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridLiftoffAdsSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `HybridLiftoffInterstitialAdSpec` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::liftoffads { class HybridLiftoffInterstitialAdSpec; }
|
|
12
|
+
// Forward declaration of `HybridLiftoffRewardedAdSpec` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::liftoffads { class HybridLiftoffRewardedAdSpec; }
|
|
14
|
+
|
|
15
|
+
#include <NitroModules/Promise.hpp>
|
|
16
|
+
#include <NitroModules/JPromise.hpp>
|
|
17
|
+
#include <memory>
|
|
18
|
+
#include "HybridLiftoffInterstitialAdSpec.hpp"
|
|
19
|
+
#include "JHybridLiftoffInterstitialAdSpec.hpp"
|
|
20
|
+
#include "HybridLiftoffRewardedAdSpec.hpp"
|
|
21
|
+
#include "JHybridLiftoffRewardedAdSpec.hpp"
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
namespace margelo::nitro::liftoffads {
|
|
25
|
+
|
|
26
|
+
jni::local_ref<JHybridLiftoffAdsSpec::jhybriddata> JHybridLiftoffAdsSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
27
|
+
return makeCxxInstance(jThis);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void JHybridLiftoffAdsSpec::registerNatives() {
|
|
31
|
+
registerHybrid({
|
|
32
|
+
makeNativeMethod("initHybrid", JHybridLiftoffAdsSpec::initHybrid),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
size_t JHybridLiftoffAdsSpec::getExternalMemorySize() noexcept {
|
|
37
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
38
|
+
return method(_javaPart);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void JHybridLiftoffAdsSpec::dispose() noexcept {
|
|
42
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
43
|
+
method(_javaPart);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Properties
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// Methods
|
|
50
|
+
std::shared_ptr<Promise<void>> JHybridLiftoffAdsSpec::initialize(const std::string& appId) {
|
|
51
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* appId */)>("initialize");
|
|
52
|
+
auto __result = method(_javaPart, jni::make_jstring(appId));
|
|
53
|
+
return [&]() {
|
|
54
|
+
auto __promise = Promise<void>::create();
|
|
55
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
56
|
+
__promise->resolve();
|
|
57
|
+
});
|
|
58
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
59
|
+
jni::JniException __jniError(__throwable);
|
|
60
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
61
|
+
});
|
|
62
|
+
return __promise;
|
|
63
|
+
}();
|
|
64
|
+
}
|
|
65
|
+
void JHybridLiftoffAdsSpec::setGDPRConsent(bool optIn, const std::string& consentMessageVersion) {
|
|
66
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* optIn */, jni::alias_ref<jni::JString> /* consentMessageVersion */)>("setGDPRConsent");
|
|
67
|
+
method(_javaPart, optIn, jni::make_jstring(consentMessageVersion));
|
|
68
|
+
}
|
|
69
|
+
void JHybridLiftoffAdsSpec::setCCPAConsent(bool optIn) {
|
|
70
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* optIn */)>("setCCPAConsent");
|
|
71
|
+
method(_javaPart, optIn);
|
|
72
|
+
}
|
|
73
|
+
void JHybridLiftoffAdsSpec::setCOPPA(bool isUserCoppa) {
|
|
74
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* isUserCoppa */)>("setCOPPA");
|
|
75
|
+
method(_javaPart, isUserCoppa);
|
|
76
|
+
}
|
|
77
|
+
std::shared_ptr<HybridLiftoffInterstitialAdSpec> JHybridLiftoffAdsSpec::createInterstitialAd(const std::string& placementId) {
|
|
78
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridLiftoffInterstitialAdSpec::javaobject>(jni::alias_ref<jni::JString> /* placementId */)>("createInterstitialAd");
|
|
79
|
+
auto __result = method(_javaPart, jni::make_jstring(placementId));
|
|
80
|
+
return __result->cthis()->shared_cast<JHybridLiftoffInterstitialAdSpec>();
|
|
81
|
+
}
|
|
82
|
+
std::shared_ptr<HybridLiftoffRewardedAdSpec> JHybridLiftoffAdsSpec::createRewardedAd(const std::string& placementId) {
|
|
83
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridLiftoffRewardedAdSpec::javaobject>(jni::alias_ref<jni::JString> /* placementId */)>("createRewardedAd");
|
|
84
|
+
auto __result = method(_javaPart, jni::make_jstring(placementId));
|
|
85
|
+
return __result->cthis()->shared_cast<JHybridLiftoffRewardedAdSpec>();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffAdsSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridLiftoffAdsSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::liftoffads {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridLiftoffAdsSpec: public jni::HybridClass<JHybridLiftoffAdsSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridLiftoffAdsSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/liftoffads/HybridLiftoffAdsSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridLiftoffAdsSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridLiftoffAdsSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridLiftoffAdsSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
inline const jni::global_ref<JHybridLiftoffAdsSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
return _javaPart;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Properties
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Methods
|
|
56
|
+
std::shared_ptr<Promise<void>> initialize(const std::string& appId) override;
|
|
57
|
+
void setGDPRConsent(bool optIn, const std::string& consentMessageVersion) override;
|
|
58
|
+
void setCCPAConsent(bool optIn) override;
|
|
59
|
+
void setCOPPA(bool isUserCoppa) override;
|
|
60
|
+
std::shared_ptr<HybridLiftoffInterstitialAdSpec> createInterstitialAd(const std::string& placementId) override;
|
|
61
|
+
std::shared_ptr<HybridLiftoffRewardedAdSpec> createRewardedAd(const std::string& placementId) override;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
friend HybridBase;
|
|
65
|
+
using HybridBase::HybridBase;
|
|
66
|
+
jni::global_ref<JHybridLiftoffAdsSpec::javaobject> _javaPart;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridLiftoffInterstitialAdSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridLiftoffInterstitialAdSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `LiftoffAdShowOptions` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdShowOptions; }
|
|
12
|
+
// Forward declaration of `LiftoffAdEventType` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::liftoffads { enum class LiftoffAdEventType; }
|
|
14
|
+
// Forward declaration of `LiftoffAdEventPayload` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdEventPayload; }
|
|
16
|
+
|
|
17
|
+
#include <NitroModules/Promise.hpp>
|
|
18
|
+
#include <NitroModules/JPromise.hpp>
|
|
19
|
+
#include "LiftoffAdShowOptions.hpp"
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include "JLiftoffAdShowOptions.hpp"
|
|
22
|
+
#include "LiftoffAdEventType.hpp"
|
|
23
|
+
#include "JLiftoffAdEventType.hpp"
|
|
24
|
+
#include "LiftoffAdEventPayload.hpp"
|
|
25
|
+
#include <functional>
|
|
26
|
+
#include "JFunc_void_std__optional_LiftoffAdEventPayload_.hpp"
|
|
27
|
+
#include "JLiftoffAdEventPayload.hpp"
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::liftoffads {
|
|
31
|
+
|
|
32
|
+
jni::local_ref<JHybridLiftoffInterstitialAdSpec::jhybriddata> JHybridLiftoffInterstitialAdSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
33
|
+
return makeCxxInstance(jThis);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void JHybridLiftoffInterstitialAdSpec::registerNatives() {
|
|
37
|
+
registerHybrid({
|
|
38
|
+
makeNativeMethod("initHybrid", JHybridLiftoffInterstitialAdSpec::initHybrid),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
size_t JHybridLiftoffInterstitialAdSpec::getExternalMemorySize() noexcept {
|
|
43
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
44
|
+
return method(_javaPart);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void JHybridLiftoffInterstitialAdSpec::dispose() noexcept {
|
|
48
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
49
|
+
method(_javaPart);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// Methods
|
|
56
|
+
void JHybridLiftoffInterstitialAdSpec::load() {
|
|
57
|
+
static const auto method = javaClassStatic()->getMethod<void()>("load");
|
|
58
|
+
method(_javaPart);
|
|
59
|
+
}
|
|
60
|
+
std::shared_ptr<Promise<void>> JHybridLiftoffInterstitialAdSpec::show(const std::optional<LiftoffAdShowOptions>& options) {
|
|
61
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JLiftoffAdShowOptions> /* options */)>("show");
|
|
62
|
+
auto __result = method(_javaPart, options.has_value() ? JLiftoffAdShowOptions::fromCpp(options.value()) : nullptr);
|
|
63
|
+
return [&]() {
|
|
64
|
+
auto __promise = Promise<void>::create();
|
|
65
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
66
|
+
__promise->resolve();
|
|
67
|
+
});
|
|
68
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
69
|
+
jni::JniException __jniError(__throwable);
|
|
70
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
71
|
+
});
|
|
72
|
+
return __promise;
|
|
73
|
+
}();
|
|
74
|
+
}
|
|
75
|
+
double JHybridLiftoffInterstitialAdSpec::addAdEventListener(LiftoffAdEventType eventType, const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& listener) {
|
|
76
|
+
static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<JLiftoffAdEventType> /* eventType */, jni::alias_ref<JFunc_void_std__optional_LiftoffAdEventPayload_::javaobject> /* listener */)>("addAdEventListener_cxx");
|
|
77
|
+
auto __result = method(_javaPart, JLiftoffAdEventType::fromCpp(eventType), JFunc_void_std__optional_LiftoffAdEventPayload__cxx::fromCpp(listener));
|
|
78
|
+
return __result;
|
|
79
|
+
}
|
|
80
|
+
void JHybridLiftoffInterstitialAdSpec::removeAdEventListener(double subscriptionId) {
|
|
81
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* subscriptionId */)>("removeAdEventListener");
|
|
82
|
+
method(_javaPart, subscriptionId);
|
|
83
|
+
}
|
|
84
|
+
void JHybridLiftoffInterstitialAdSpec::removeAllListeners() {
|
|
85
|
+
static const auto method = javaClassStatic()->getMethod<void()>("removeAllListeners");
|
|
86
|
+
method(_javaPart);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffInterstitialAdSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridLiftoffInterstitialAdSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::liftoffads {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridLiftoffInterstitialAdSpec: public jni::HybridClass<JHybridLiftoffInterstitialAdSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridLiftoffInterstitialAdSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/liftoffads/HybridLiftoffInterstitialAdSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridLiftoffInterstitialAdSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridLiftoffInterstitialAdSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridLiftoffInterstitialAdSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
inline const jni::global_ref<JHybridLiftoffInterstitialAdSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
return _javaPart;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Properties
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Methods
|
|
56
|
+
void load() override;
|
|
57
|
+
std::shared_ptr<Promise<void>> show(const std::optional<LiftoffAdShowOptions>& options) override;
|
|
58
|
+
double addAdEventListener(LiftoffAdEventType eventType, const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& listener) override;
|
|
59
|
+
void removeAdEventListener(double subscriptionId) override;
|
|
60
|
+
void removeAllListeners() override;
|
|
61
|
+
|
|
62
|
+
private:
|
|
63
|
+
friend HybridBase;
|
|
64
|
+
using HybridBase::HybridBase;
|
|
65
|
+
jni::global_ref<JHybridLiftoffInterstitialAdSpec::javaobject> _javaPart;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridLiftoffRewardedAdSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridLiftoffRewardedAdSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `LiftoffAdShowOptions` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdShowOptions; }
|
|
12
|
+
// Forward declaration of `LiftoffAdEventType` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::liftoffads { enum class LiftoffAdEventType; }
|
|
14
|
+
// Forward declaration of `LiftoffAdEventPayload` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdEventPayload; }
|
|
16
|
+
|
|
17
|
+
#include <NitroModules/Promise.hpp>
|
|
18
|
+
#include <NitroModules/JPromise.hpp>
|
|
19
|
+
#include <string>
|
|
20
|
+
#include "LiftoffAdShowOptions.hpp"
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include "JLiftoffAdShowOptions.hpp"
|
|
23
|
+
#include "LiftoffAdEventType.hpp"
|
|
24
|
+
#include "JLiftoffAdEventType.hpp"
|
|
25
|
+
#include "LiftoffAdEventPayload.hpp"
|
|
26
|
+
#include <functional>
|
|
27
|
+
#include "JFunc_void_std__optional_LiftoffAdEventPayload_.hpp"
|
|
28
|
+
#include "JLiftoffAdEventPayload.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::liftoffads {
|
|
31
|
+
|
|
32
|
+
jni::local_ref<JHybridLiftoffRewardedAdSpec::jhybriddata> JHybridLiftoffRewardedAdSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
33
|
+
return makeCxxInstance(jThis);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void JHybridLiftoffRewardedAdSpec::registerNatives() {
|
|
37
|
+
registerHybrid({
|
|
38
|
+
makeNativeMethod("initHybrid", JHybridLiftoffRewardedAdSpec::initHybrid),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
size_t JHybridLiftoffRewardedAdSpec::getExternalMemorySize() noexcept {
|
|
43
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
44
|
+
return method(_javaPart);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void JHybridLiftoffRewardedAdSpec::dispose() noexcept {
|
|
48
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
49
|
+
method(_javaPart);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// Methods
|
|
56
|
+
void JHybridLiftoffRewardedAdSpec::load() {
|
|
57
|
+
static const auto method = javaClassStatic()->getMethod<void()>("load");
|
|
58
|
+
method(_javaPart);
|
|
59
|
+
}
|
|
60
|
+
void JHybridLiftoffRewardedAdSpec::setUserId(const std::string& userId) {
|
|
61
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* userId */)>("setUserId");
|
|
62
|
+
method(_javaPart, jni::make_jstring(userId));
|
|
63
|
+
}
|
|
64
|
+
std::shared_ptr<Promise<void>> JHybridLiftoffRewardedAdSpec::show(const std::optional<LiftoffAdShowOptions>& options) {
|
|
65
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JLiftoffAdShowOptions> /* options */)>("show");
|
|
66
|
+
auto __result = method(_javaPart, options.has_value() ? JLiftoffAdShowOptions::fromCpp(options.value()) : nullptr);
|
|
67
|
+
return [&]() {
|
|
68
|
+
auto __promise = Promise<void>::create();
|
|
69
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
70
|
+
__promise->resolve();
|
|
71
|
+
});
|
|
72
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
73
|
+
jni::JniException __jniError(__throwable);
|
|
74
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
75
|
+
});
|
|
76
|
+
return __promise;
|
|
77
|
+
}();
|
|
78
|
+
}
|
|
79
|
+
double JHybridLiftoffRewardedAdSpec::addAdEventListener(LiftoffAdEventType eventType, const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& listener) {
|
|
80
|
+
static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<JLiftoffAdEventType> /* eventType */, jni::alias_ref<JFunc_void_std__optional_LiftoffAdEventPayload_::javaobject> /* listener */)>("addAdEventListener_cxx");
|
|
81
|
+
auto __result = method(_javaPart, JLiftoffAdEventType::fromCpp(eventType), JFunc_void_std__optional_LiftoffAdEventPayload__cxx::fromCpp(listener));
|
|
82
|
+
return __result;
|
|
83
|
+
}
|
|
84
|
+
void JHybridLiftoffRewardedAdSpec::removeAdEventListener(double subscriptionId) {
|
|
85
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* subscriptionId */)>("removeAdEventListener");
|
|
86
|
+
method(_javaPart, subscriptionId);
|
|
87
|
+
}
|
|
88
|
+
void JHybridLiftoffRewardedAdSpec::removeAllListeners() {
|
|
89
|
+
static const auto method = javaClassStatic()->getMethod<void()>("removeAllListeners");
|
|
90
|
+
method(_javaPart);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro::liftoffads
|