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,114 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffAdsSpecSwift.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 "HybridLiftoffAdsSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridLiftoffAdsSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroLiftoffAds { class HybridLiftoffAdsSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `HybridLiftoffInterstitialAdSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::liftoffads { class HybridLiftoffInterstitialAdSpec; }
|
|
17
|
+
// Forward declaration of `HybridLiftoffRewardedAdSpec` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::liftoffads { class HybridLiftoffRewardedAdSpec; }
|
|
19
|
+
|
|
20
|
+
#include <NitroModules/Promise.hpp>
|
|
21
|
+
#include <string>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include "HybridLiftoffInterstitialAdSpec.hpp"
|
|
24
|
+
#include "HybridLiftoffRewardedAdSpec.hpp"
|
|
25
|
+
|
|
26
|
+
#include "NitroLiftoffAds-Swift-Cxx-Umbrella.hpp"
|
|
27
|
+
|
|
28
|
+
namespace margelo::nitro::liftoffads {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The C++ part of HybridLiftoffAdsSpec_cxx.swift.
|
|
32
|
+
*
|
|
33
|
+
* HybridLiftoffAdsSpecSwift (C++) accesses HybridLiftoffAdsSpec_cxx (Swift), and might
|
|
34
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
35
|
+
*
|
|
36
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
37
|
+
* the future, HybridLiftoffAdsSpec_cxx can directly inherit from the C++ class HybridLiftoffAdsSpec
|
|
38
|
+
* to simplify the whole structure and memory management.
|
|
39
|
+
*/
|
|
40
|
+
class HybridLiftoffAdsSpecSwift: public virtual HybridLiftoffAdsSpec {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor from a Swift instance
|
|
43
|
+
explicit HybridLiftoffAdsSpecSwift(const NitroLiftoffAds::HybridLiftoffAdsSpec_cxx& swiftPart):
|
|
44
|
+
HybridObject(HybridLiftoffAdsSpec::TAG),
|
|
45
|
+
_swiftPart(swiftPart) { }
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Get the Swift part
|
|
49
|
+
inline NitroLiftoffAds::HybridLiftoffAdsSpec_cxx& getSwiftPart() noexcept {
|
|
50
|
+
return _swiftPart;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
55
|
+
return _swiftPart.getMemorySize();
|
|
56
|
+
}
|
|
57
|
+
void dispose() noexcept override {
|
|
58
|
+
_swiftPart.dispose();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Properties
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Methods
|
|
67
|
+
inline std::shared_ptr<Promise<void>> initialize(const std::string& appId) override {
|
|
68
|
+
auto __result = _swiftPart.initialize(appId);
|
|
69
|
+
if (__result.hasError()) [[unlikely]] {
|
|
70
|
+
std::rethrow_exception(__result.error());
|
|
71
|
+
}
|
|
72
|
+
auto __value = std::move(__result.value());
|
|
73
|
+
return __value;
|
|
74
|
+
}
|
|
75
|
+
inline void setGDPRConsent(bool optIn, const std::string& consentMessageVersion) override {
|
|
76
|
+
auto __result = _swiftPart.setGDPRConsent(std::forward<decltype(optIn)>(optIn), consentMessageVersion);
|
|
77
|
+
if (__result.hasError()) [[unlikely]] {
|
|
78
|
+
std::rethrow_exception(__result.error());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
inline void setCCPAConsent(bool optIn) override {
|
|
82
|
+
auto __result = _swiftPart.setCCPAConsent(std::forward<decltype(optIn)>(optIn));
|
|
83
|
+
if (__result.hasError()) [[unlikely]] {
|
|
84
|
+
std::rethrow_exception(__result.error());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
inline void setCOPPA(bool isUserCoppa) override {
|
|
88
|
+
auto __result = _swiftPart.setCOPPA(std::forward<decltype(isUserCoppa)>(isUserCoppa));
|
|
89
|
+
if (__result.hasError()) [[unlikely]] {
|
|
90
|
+
std::rethrow_exception(__result.error());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
inline std::shared_ptr<HybridLiftoffInterstitialAdSpec> createInterstitialAd(const std::string& placementId) override {
|
|
94
|
+
auto __result = _swiftPart.createInterstitialAd(placementId);
|
|
95
|
+
if (__result.hasError()) [[unlikely]] {
|
|
96
|
+
std::rethrow_exception(__result.error());
|
|
97
|
+
}
|
|
98
|
+
auto __value = std::move(__result.value());
|
|
99
|
+
return __value;
|
|
100
|
+
}
|
|
101
|
+
inline std::shared_ptr<HybridLiftoffRewardedAdSpec> createRewardedAd(const std::string& placementId) override {
|
|
102
|
+
auto __result = _swiftPart.createRewardedAd(placementId);
|
|
103
|
+
if (__result.hasError()) [[unlikely]] {
|
|
104
|
+
std::rethrow_exception(__result.error());
|
|
105
|
+
}
|
|
106
|
+
auto __value = std::move(__result.value());
|
|
107
|
+
return __value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private:
|
|
111
|
+
NitroLiftoffAds::HybridLiftoffAdsSpec_cxx _swiftPart;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffInterstitialAdSpecSwift.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 "HybridLiftoffInterstitialAdSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::liftoffads {
|
|
11
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffInterstitialAdSpecSwift.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 "HybridLiftoffInterstitialAdSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridLiftoffInterstitialAdSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroLiftoffAds { class HybridLiftoffInterstitialAdSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `LiftoffAdShowOptions` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdShowOptions; }
|
|
17
|
+
// Forward declaration of `LiftoffAdEventType` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::liftoffads { enum class LiftoffAdEventType; }
|
|
19
|
+
// Forward declaration of `LiftoffAdEventPayload` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdEventPayload; }
|
|
21
|
+
|
|
22
|
+
#include <NitroModules/Promise.hpp>
|
|
23
|
+
#include "LiftoffAdShowOptions.hpp"
|
|
24
|
+
#include <optional>
|
|
25
|
+
#include "LiftoffAdEventType.hpp"
|
|
26
|
+
#include "LiftoffAdEventPayload.hpp"
|
|
27
|
+
#include <functional>
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
#include "NitroLiftoffAds-Swift-Cxx-Umbrella.hpp"
|
|
31
|
+
|
|
32
|
+
namespace margelo::nitro::liftoffads {
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The C++ part of HybridLiftoffInterstitialAdSpec_cxx.swift.
|
|
36
|
+
*
|
|
37
|
+
* HybridLiftoffInterstitialAdSpecSwift (C++) accesses HybridLiftoffInterstitialAdSpec_cxx (Swift), and might
|
|
38
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
39
|
+
*
|
|
40
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
41
|
+
* the future, HybridLiftoffInterstitialAdSpec_cxx can directly inherit from the C++ class HybridLiftoffInterstitialAdSpec
|
|
42
|
+
* to simplify the whole structure and memory management.
|
|
43
|
+
*/
|
|
44
|
+
class HybridLiftoffInterstitialAdSpecSwift: public virtual HybridLiftoffInterstitialAdSpec {
|
|
45
|
+
public:
|
|
46
|
+
// Constructor from a Swift instance
|
|
47
|
+
explicit HybridLiftoffInterstitialAdSpecSwift(const NitroLiftoffAds::HybridLiftoffInterstitialAdSpec_cxx& swiftPart):
|
|
48
|
+
HybridObject(HybridLiftoffInterstitialAdSpec::TAG),
|
|
49
|
+
_swiftPart(swiftPart) { }
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Get the Swift part
|
|
53
|
+
inline NitroLiftoffAds::HybridLiftoffInterstitialAdSpec_cxx& getSwiftPart() noexcept {
|
|
54
|
+
return _swiftPart;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
59
|
+
return _swiftPart.getMemorySize();
|
|
60
|
+
}
|
|
61
|
+
void dispose() noexcept override {
|
|
62
|
+
_swiftPart.dispose();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Properties
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Methods
|
|
71
|
+
inline void load() override {
|
|
72
|
+
auto __result = _swiftPart.load();
|
|
73
|
+
if (__result.hasError()) [[unlikely]] {
|
|
74
|
+
std::rethrow_exception(__result.error());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
inline std::shared_ptr<Promise<void>> show(const std::optional<LiftoffAdShowOptions>& options) override {
|
|
78
|
+
auto __result = _swiftPart.show(options);
|
|
79
|
+
if (__result.hasError()) [[unlikely]] {
|
|
80
|
+
std::rethrow_exception(__result.error());
|
|
81
|
+
}
|
|
82
|
+
auto __value = std::move(__result.value());
|
|
83
|
+
return __value;
|
|
84
|
+
}
|
|
85
|
+
inline double addAdEventListener(LiftoffAdEventType eventType, const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& listener) override {
|
|
86
|
+
auto __result = _swiftPart.addAdEventListener(static_cast<int>(eventType), listener);
|
|
87
|
+
if (__result.hasError()) [[unlikely]] {
|
|
88
|
+
std::rethrow_exception(__result.error());
|
|
89
|
+
}
|
|
90
|
+
auto __value = std::move(__result.value());
|
|
91
|
+
return __value;
|
|
92
|
+
}
|
|
93
|
+
inline void removeAdEventListener(double subscriptionId) override {
|
|
94
|
+
auto __result = _swiftPart.removeAdEventListener(std::forward<decltype(subscriptionId)>(subscriptionId));
|
|
95
|
+
if (__result.hasError()) [[unlikely]] {
|
|
96
|
+
std::rethrow_exception(__result.error());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
inline void removeAllListeners() override {
|
|
100
|
+
auto __result = _swiftPart.removeAllListeners();
|
|
101
|
+
if (__result.hasError()) [[unlikely]] {
|
|
102
|
+
std::rethrow_exception(__result.error());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private:
|
|
107
|
+
NitroLiftoffAds::HybridLiftoffInterstitialAdSpec_cxx _swiftPart;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffRewardedAdSpecSwift.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 "HybridLiftoffRewardedAdSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::liftoffads {
|
|
11
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffRewardedAdSpecSwift.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 "HybridLiftoffRewardedAdSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridLiftoffRewardedAdSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroLiftoffAds { class HybridLiftoffRewardedAdSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `LiftoffAdShowOptions` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdShowOptions; }
|
|
17
|
+
// Forward declaration of `LiftoffAdEventType` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::liftoffads { enum class LiftoffAdEventType; }
|
|
19
|
+
// Forward declaration of `LiftoffAdEventPayload` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::liftoffads { struct LiftoffAdEventPayload; }
|
|
21
|
+
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include "LiftoffAdShowOptions.hpp"
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include "LiftoffAdEventType.hpp"
|
|
27
|
+
#include "LiftoffAdEventPayload.hpp"
|
|
28
|
+
#include <functional>
|
|
29
|
+
|
|
30
|
+
#include "NitroLiftoffAds-Swift-Cxx-Umbrella.hpp"
|
|
31
|
+
|
|
32
|
+
namespace margelo::nitro::liftoffads {
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The C++ part of HybridLiftoffRewardedAdSpec_cxx.swift.
|
|
36
|
+
*
|
|
37
|
+
* HybridLiftoffRewardedAdSpecSwift (C++) accesses HybridLiftoffRewardedAdSpec_cxx (Swift), and might
|
|
38
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
39
|
+
*
|
|
40
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
41
|
+
* the future, HybridLiftoffRewardedAdSpec_cxx can directly inherit from the C++ class HybridLiftoffRewardedAdSpec
|
|
42
|
+
* to simplify the whole structure and memory management.
|
|
43
|
+
*/
|
|
44
|
+
class HybridLiftoffRewardedAdSpecSwift: public virtual HybridLiftoffRewardedAdSpec {
|
|
45
|
+
public:
|
|
46
|
+
// Constructor from a Swift instance
|
|
47
|
+
explicit HybridLiftoffRewardedAdSpecSwift(const NitroLiftoffAds::HybridLiftoffRewardedAdSpec_cxx& swiftPart):
|
|
48
|
+
HybridObject(HybridLiftoffRewardedAdSpec::TAG),
|
|
49
|
+
_swiftPart(swiftPart) { }
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Get the Swift part
|
|
53
|
+
inline NitroLiftoffAds::HybridLiftoffRewardedAdSpec_cxx& getSwiftPart() noexcept {
|
|
54
|
+
return _swiftPart;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
59
|
+
return _swiftPart.getMemorySize();
|
|
60
|
+
}
|
|
61
|
+
void dispose() noexcept override {
|
|
62
|
+
_swiftPart.dispose();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Properties
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Methods
|
|
71
|
+
inline void load() override {
|
|
72
|
+
auto __result = _swiftPart.load();
|
|
73
|
+
if (__result.hasError()) [[unlikely]] {
|
|
74
|
+
std::rethrow_exception(__result.error());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
inline void setUserId(const std::string& userId) override {
|
|
78
|
+
auto __result = _swiftPart.setUserId(userId);
|
|
79
|
+
if (__result.hasError()) [[unlikely]] {
|
|
80
|
+
std::rethrow_exception(__result.error());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
inline std::shared_ptr<Promise<void>> show(const std::optional<LiftoffAdShowOptions>& options) override {
|
|
84
|
+
auto __result = _swiftPart.show(options);
|
|
85
|
+
if (__result.hasError()) [[unlikely]] {
|
|
86
|
+
std::rethrow_exception(__result.error());
|
|
87
|
+
}
|
|
88
|
+
auto __value = std::move(__result.value());
|
|
89
|
+
return __value;
|
|
90
|
+
}
|
|
91
|
+
inline double addAdEventListener(LiftoffAdEventType eventType, const std::function<void(const std::optional<LiftoffAdEventPayload>& /* payload */)>& listener) override {
|
|
92
|
+
auto __result = _swiftPart.addAdEventListener(static_cast<int>(eventType), listener);
|
|
93
|
+
if (__result.hasError()) [[unlikely]] {
|
|
94
|
+
std::rethrow_exception(__result.error());
|
|
95
|
+
}
|
|
96
|
+
auto __value = std::move(__result.value());
|
|
97
|
+
return __value;
|
|
98
|
+
}
|
|
99
|
+
inline void removeAdEventListener(double subscriptionId) override {
|
|
100
|
+
auto __result = _swiftPart.removeAdEventListener(std::forward<decltype(subscriptionId)>(subscriptionId));
|
|
101
|
+
if (__result.hasError()) [[unlikely]] {
|
|
102
|
+
std::rethrow_exception(__result.error());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
inline void removeAllListeners() override {
|
|
106
|
+
auto __result = _swiftPart.removeAllListeners();
|
|
107
|
+
if (__result.hasError()) [[unlikely]] {
|
|
108
|
+
std::rethrow_exception(__result.error());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private:
|
|
113
|
+
NitroLiftoffAds::HybridLiftoffRewardedAdSpec_cxx _swiftPart;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
} // namespace margelo::nitro::liftoffads
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void {
|
|
16
|
+
public typealias bridge = margelo.nitro.liftoffads.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: () -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping () -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call() -> Void {
|
|
26
|
+
self.closure()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
45
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__exception_ptr {
|
|
16
|
+
public typealias bridge = margelo.nitro.liftoffads.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ error: Error) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
26
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
45
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__optional_LiftoffAdEventPayload_.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ payload: LiftoffAdEventPayload?) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__optional_LiftoffAdEventPayload_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.liftoffads.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ payload: LiftoffAdEventPayload?) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ payload: LiftoffAdEventPayload?) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(payload: bridge.std__optional_LiftoffAdEventPayload_) -> Void {
|
|
26
|
+
self.closure({ () -> LiftoffAdEventPayload? in
|
|
27
|
+
if bridge.has_value_std__optional_LiftoffAdEventPayload_(payload) {
|
|
28
|
+
let __unwrapped = bridge.get_std__optional_LiftoffAdEventPayload_(payload)
|
|
29
|
+
return __unwrapped
|
|
30
|
+
} else {
|
|
31
|
+
return nil
|
|
32
|
+
}
|
|
33
|
+
}())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
38
|
+
* This acquires one additional strong reference on the object!
|
|
39
|
+
*/
|
|
40
|
+
@inline(__always)
|
|
41
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
42
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Casts an unsafe pointer to a `Func_void_std__optional_LiftoffAdEventPayload_`.
|
|
47
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_LiftoffAdEventPayload_>`.
|
|
48
|
+
* This removes one strong reference from the object!
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_LiftoffAdEventPayload_ {
|
|
52
|
+
return Unmanaged<Func_void_std__optional_LiftoffAdEventPayload_>.fromOpaque(pointer).takeRetainedValue()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiftoffAdsSpec.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridLiftoffAdsSpec``
|
|
12
|
+
public protocol HybridLiftoffAdsSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func initialize(appId: String) throws -> Promise<Void>
|
|
18
|
+
func setGDPRConsent(optIn: Bool, consentMessageVersion: String) throws -> Void
|
|
19
|
+
func setCCPAConsent(optIn: Bool) throws -> Void
|
|
20
|
+
func setCOPPA(isUserCoppa: Bool) throws -> Void
|
|
21
|
+
func createInterstitialAd(placementId: String) throws -> (any HybridLiftoffInterstitialAdSpec)
|
|
22
|
+
func createRewardedAd(placementId: String) throws -> (any HybridLiftoffRewardedAdSpec)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// See ``HybridLiftoffAdsSpec``
|
|
26
|
+
open class HybridLiftoffAdsSpec_base {
|
|
27
|
+
private weak var cxxWrapper: HybridLiftoffAdsSpec_cxx? = nil
|
|
28
|
+
public init() { }
|
|
29
|
+
public func getCxxWrapper() -> HybridLiftoffAdsSpec_cxx {
|
|
30
|
+
#if DEBUG
|
|
31
|
+
guard self is HybridLiftoffAdsSpec else {
|
|
32
|
+
fatalError("`self` is not a `HybridLiftoffAdsSpec`! Did you accidentally inherit from `HybridLiftoffAdsSpec_base` instead of `HybridLiftoffAdsSpec`?")
|
|
33
|
+
}
|
|
34
|
+
#endif
|
|
35
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
36
|
+
return cxxWrapper
|
|
37
|
+
} else {
|
|
38
|
+
let cxxWrapper = HybridLiftoffAdsSpec_cxx(self as! HybridLiftoffAdsSpec)
|
|
39
|
+
self.cxxWrapper = cxxWrapper
|
|
40
|
+
return cxxWrapper
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A Swift base-protocol representing the LiftoffAds HybridObject.
|
|
47
|
+
* Implement this protocol to create Swift-based instances of LiftoffAds.
|
|
48
|
+
* ```swift
|
|
49
|
+
* class HybridLiftoffAds : HybridLiftoffAdsSpec {
|
|
50
|
+
* // ...
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
public typealias HybridLiftoffAdsSpec = HybridLiftoffAdsSpec_protocol & HybridLiftoffAdsSpec_base
|