react-native-carrot-quest 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CarrotQuest.podspec +34 -0
- package/LICENSE +20 -0
- package/README.md +457 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +136 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuest.kt +585 -0
- package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestSetup.kt +472 -0
- package/ios/CarrotQuest.swift +588 -0
- package/ios/CarrotQuestSetup.swift +333 -0
- package/lib/module/CarrotQuest.nitro.js +4 -0
- package/lib/module/CarrotQuest.nitro.js.map +1 -0
- package/lib/module/carrot-quest.js +136 -0
- package/lib/module/carrot-quest.js.map +1 -0
- package/lib/module/carrot-quest.native.js +155 -0
- package/lib/module/carrot-quest.native.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/subscriptions.js +76 -0
- package/lib/module/subscriptions.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/CarrotQuest.nitro.d.ts +394 -0
- package/lib/typescript/src/CarrotQuest.nitro.d.ts.map +1 -0
- package/lib/typescript/src/carrot-quest.d.ts +37 -0
- package/lib/typescript/src/carrot-quest.d.ts.map +1 -0
- package/lib/typescript/src/carrot-quest.native.d.ts +37 -0
- package/lib/typescript/src/carrot-quest.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/subscriptions.d.ts +32 -0
- package/lib/typescript/src/subscriptions.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JCarrotQuestEventValue.cpp +30 -0
- package/nitrogen/generated/android/c++/JCarrotQuestEventValue.hpp +83 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogCategory.hpp +76 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogEntry.hpp +100 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogLevel.hpp +70 -0
- package/nitrogen/generated/android/c++/JCarrotQuestProperty.hpp +74 -0
- package/nitrogen/generated/android/c++/JCarrotQuestPropertyKind.hpp +61 -0
- package/nitrogen/generated/android/c++/JCarrotQuestPropertyOperation.hpp +73 -0
- package/nitrogen/generated/android/c++/JCarrotQuestSetupOptions.hpp +94 -0
- package/nitrogen/generated/android/c++/JCarrotQuestTheme.hpp +64 -0
- package/nitrogen/generated/android/c++/JCarrotQuestUrlSource.hpp +64 -0
- package/nitrogen/generated/android/c++/JCarrotQuestUserProperties.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_CarrotQuestLogEntry.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.cpp +388 -0
- package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.hpp +96 -0
- package/nitrogen/generated/android/carrotquest+autolinking.cmake +82 -0
- package/nitrogen/generated/android/carrotquest+autolinking.gradle +27 -0
- package/nitrogen/generated/android/carrotquestOnLoad.cpp +62 -0
- package/nitrogen/generated/android/carrotquestOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestEventValue.kt +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogCategory.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogEntry.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogLevel.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestProperty.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyKind.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyOperation.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestSetupOptions.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestTheme.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUrlSource.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUserProperties.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_CarrotQuestLogEntry.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/HybridCarrotQuestSpec.kt +209 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/carrotquestOnLoad.kt +35 -0
- package/nitrogen/generated/ios/CarrotQuest+autolinking.rb +62 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.cpp +97 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.hpp +637 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Umbrella.hpp +80 -0
- package/nitrogen/generated/ios/CarrotQuestAutolinking.mm +33 -0
- package/nitrogen/generated/ios/CarrotQuestAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.hpp +344 -0
- package/nitrogen/generated/ios/swift/CarrotQuestEventValue.swift +32 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogCategory.swift +64 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogEntry.swift +86 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogLevel.swift +56 -0
- package/nitrogen/generated/ios/swift/CarrotQuestProperty.swift +56 -0
- package/nitrogen/generated/ios/swift/CarrotQuestPropertyKind.swift +44 -0
- package/nitrogen/generated/ios/swift/CarrotQuestPropertyOperation.swift +60 -0
- package/nitrogen/generated/ios/swift/CarrotQuestSetupOptions.swift +172 -0
- package/nitrogen/generated/ios/swift/CarrotQuestTheme.swift +48 -0
- package/nitrogen/generated/ios/swift/CarrotQuestUrlSource.swift +48 -0
- package/nitrogen/generated/ios/swift/CarrotQuestUserProperties.swift +110 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CarrotQuestLogEntry.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_double_.swift +53 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec.swift +88 -0
- package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec_cxx.swift +674 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogCategory.hpp +100 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogEntry.hpp +114 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogLevel.hpp +92 -0
- package/nitrogen/generated/shared/c++/CarrotQuestProperty.hpp +101 -0
- package/nitrogen/generated/shared/c++/CarrotQuestPropertyKind.hpp +80 -0
- package/nitrogen/generated/shared/c++/CarrotQuestPropertyOperation.hpp +96 -0
- package/nitrogen/generated/shared/c++/CarrotQuestSetupOptions.hpp +121 -0
- package/nitrogen/generated/shared/c++/CarrotQuestTheme.hpp +84 -0
- package/nitrogen/generated/shared/c++/CarrotQuestUrlSource.hpp +84 -0
- package/nitrogen/generated/shared/c++/CarrotQuestUserProperties.hpp +97 -0
- package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.cpp +55 -0
- package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.hpp +118 -0
- package/package.json +140 -0
- package/src/CarrotQuest.nitro.ts +493 -0
- package/src/carrot-quest.native.tsx +241 -0
- package/src/carrot-quest.tsx +207 -0
- package/src/index.tsx +57 -0
- package/src/subscriptions.ts +83 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridCarrotQuestSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridCarrotQuestSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `CarrotQuestSetupOptions` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::carrotquest { struct CarrotQuestSetupOptions; }
|
|
12
|
+
// Forward declaration of `CarrotQuestTheme` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestTheme; }
|
|
14
|
+
// Forward declaration of `CarrotQuestLogLevel` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestLogLevel; }
|
|
16
|
+
// Forward declaration of `CarrotQuestUserProperties` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::carrotquest { struct CarrotQuestUserProperties; }
|
|
18
|
+
// Forward declaration of `CarrotQuestProperty` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::carrotquest { struct CarrotQuestProperty; }
|
|
20
|
+
// Forward declaration of `CarrotQuestPropertyOperation` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestPropertyOperation; }
|
|
22
|
+
// Forward declaration of `CarrotQuestPropertyKind` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestPropertyKind; }
|
|
24
|
+
// Forward declaration of `CarrotQuestUrlSource` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestUrlSource; }
|
|
26
|
+
// Forward declaration of `CarrotQuestLogEntry` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::carrotquest { struct CarrotQuestLogEntry; }
|
|
28
|
+
// Forward declaration of `CarrotQuestLogCategory` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestLogCategory; }
|
|
30
|
+
|
|
31
|
+
#include <NitroModules/Promise.hpp>
|
|
32
|
+
#include <NitroModules/JPromise.hpp>
|
|
33
|
+
#include <NitroModules/JUnit.hpp>
|
|
34
|
+
#include <string>
|
|
35
|
+
#include <optional>
|
|
36
|
+
#include "CarrotQuestSetupOptions.hpp"
|
|
37
|
+
#include "JCarrotQuestSetupOptions.hpp"
|
|
38
|
+
#include "CarrotQuestTheme.hpp"
|
|
39
|
+
#include "JCarrotQuestTheme.hpp"
|
|
40
|
+
#include "CarrotQuestLogLevel.hpp"
|
|
41
|
+
#include "JCarrotQuestLogLevel.hpp"
|
|
42
|
+
#include <functional>
|
|
43
|
+
#include "JFunc_void_bool.hpp"
|
|
44
|
+
#include <NitroModules/JNICallable.hpp>
|
|
45
|
+
#include "JFunc_void_double.hpp"
|
|
46
|
+
#include "CarrotQuestUserProperties.hpp"
|
|
47
|
+
#include "JCarrotQuestUserProperties.hpp"
|
|
48
|
+
#include <unordered_map>
|
|
49
|
+
#include "CarrotQuestProperty.hpp"
|
|
50
|
+
#include <vector>
|
|
51
|
+
#include "JCarrotQuestProperty.hpp"
|
|
52
|
+
#include "CarrotQuestPropertyOperation.hpp"
|
|
53
|
+
#include "JCarrotQuestPropertyOperation.hpp"
|
|
54
|
+
#include "CarrotQuestPropertyKind.hpp"
|
|
55
|
+
#include "JCarrotQuestPropertyKind.hpp"
|
|
56
|
+
#include <variant>
|
|
57
|
+
#include "JCarrotQuestEventValue.hpp"
|
|
58
|
+
#include "CarrotQuestUrlSource.hpp"
|
|
59
|
+
#include "JCarrotQuestUrlSource.hpp"
|
|
60
|
+
#include "JFunc_void_std__string.hpp"
|
|
61
|
+
#include "CarrotQuestLogEntry.hpp"
|
|
62
|
+
#include "JFunc_void_CarrotQuestLogEntry.hpp"
|
|
63
|
+
#include "JCarrotQuestLogEntry.hpp"
|
|
64
|
+
#include "CarrotQuestLogCategory.hpp"
|
|
65
|
+
#include "JCarrotQuestLogCategory.hpp"
|
|
66
|
+
|
|
67
|
+
namespace margelo::nitro::carrotquest {
|
|
68
|
+
|
|
69
|
+
std::shared_ptr<JHybridCarrotQuestSpec> JHybridCarrotQuestSpec::JavaPart::getJHybridCarrotQuestSpec() {
|
|
70
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
71
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridCarrotQuestSpec>(hybridObject);
|
|
72
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
73
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridCarrotQuestSpec!");
|
|
74
|
+
}
|
|
75
|
+
return castHybridObject;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
jni::local_ref<JHybridCarrotQuestSpec::CxxPart::jhybriddata> JHybridCarrotQuestSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
79
|
+
return makeCxxInstance(jThis);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
std::shared_ptr<JHybridObject> JHybridCarrotQuestSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
83
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridCarrotQuestSpec::JavaPart>(javaPart);
|
|
84
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
85
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridCarrotQuestSpec::JavaPart!");
|
|
86
|
+
}
|
|
87
|
+
return std::make_shared<JHybridCarrotQuestSpec>(castJavaPart);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void JHybridCarrotQuestSpec::CxxPart::registerNatives() {
|
|
91
|
+
registerHybrid({
|
|
92
|
+
makeNativeMethod("initHybrid", JHybridCarrotQuestSpec::CxxPart::initHybrid),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Properties
|
|
97
|
+
bool JHybridCarrotQuestSpec::getIsConfigured() {
|
|
98
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isConfigured");
|
|
99
|
+
auto __result = method(_javaPart);
|
|
100
|
+
return static_cast<bool>(__result);
|
|
101
|
+
}
|
|
102
|
+
bool JHybridCarrotQuestSpec::getIsChatOpen() {
|
|
103
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isChatOpen");
|
|
104
|
+
auto __result = method(_javaPart);
|
|
105
|
+
return static_cast<bool>(__result);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Methods
|
|
109
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::setup(const std::string& apiKey, const std::optional<CarrotQuestSetupOptions>& options) {
|
|
110
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* apiKey */, jni::alias_ref<JCarrotQuestSetupOptions> /* options */)>("setup");
|
|
111
|
+
auto __result = method(_javaPart, jni::make_jstring(apiKey), options.has_value() ? JCarrotQuestSetupOptions::fromCpp(options.value()) : nullptr);
|
|
112
|
+
return [&]() {
|
|
113
|
+
auto __promise = Promise<void>::create();
|
|
114
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
115
|
+
__promise->resolve();
|
|
116
|
+
});
|
|
117
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
118
|
+
jni::JniException __jniError(__throwable);
|
|
119
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
120
|
+
});
|
|
121
|
+
return __promise;
|
|
122
|
+
}();
|
|
123
|
+
}
|
|
124
|
+
std::string JHybridCarrotQuestSpec::getSdkVersion() {
|
|
125
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getSdkVersion");
|
|
126
|
+
auto __result = method(_javaPart);
|
|
127
|
+
return __result->toStdString();
|
|
128
|
+
}
|
|
129
|
+
std::shared_ptr<Promise<std::optional<std::string>>> JHybridCarrotQuestSpec::auth(const std::string& userId, const std::string& userAuthKey) {
|
|
130
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* userId */, jni::alias_ref<jni::JString> /* userAuthKey */)>("auth");
|
|
131
|
+
auto __result = method(_javaPart, jni::make_jstring(userId), jni::make_jstring(userAuthKey));
|
|
132
|
+
return [&]() {
|
|
133
|
+
auto __promise = Promise<std::optional<std::string>>::create();
|
|
134
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
135
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
136
|
+
__promise->resolve(__result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt);
|
|
137
|
+
});
|
|
138
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
139
|
+
jni::JniException __jniError(__throwable);
|
|
140
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
141
|
+
});
|
|
142
|
+
return __promise;
|
|
143
|
+
}();
|
|
144
|
+
}
|
|
145
|
+
std::shared_ptr<Promise<std::optional<std::string>>> JHybridCarrotQuestSpec::hashedAuth(const std::string& userId, const std::string& hash) {
|
|
146
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* userId */, jni::alias_ref<jni::JString> /* hash */)>("hashedAuth");
|
|
147
|
+
auto __result = method(_javaPart, jni::make_jstring(userId), jni::make_jstring(hash));
|
|
148
|
+
return [&]() {
|
|
149
|
+
auto __promise = Promise<std::optional<std::string>>::create();
|
|
150
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
151
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
152
|
+
__promise->resolve(__result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt);
|
|
153
|
+
});
|
|
154
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
155
|
+
jni::JniException __jniError(__throwable);
|
|
156
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
157
|
+
});
|
|
158
|
+
return __promise;
|
|
159
|
+
}();
|
|
160
|
+
}
|
|
161
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::logout() {
|
|
162
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("logout");
|
|
163
|
+
auto __result = method(_javaPart);
|
|
164
|
+
return [&]() {
|
|
165
|
+
auto __promise = Promise<void>::create();
|
|
166
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
167
|
+
__promise->resolve();
|
|
168
|
+
});
|
|
169
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
170
|
+
jni::JniException __jniError(__throwable);
|
|
171
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
172
|
+
});
|
|
173
|
+
return __promise;
|
|
174
|
+
}();
|
|
175
|
+
}
|
|
176
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::openChat() {
|
|
177
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("openChat");
|
|
178
|
+
auto __result = method(_javaPart);
|
|
179
|
+
return [&]() {
|
|
180
|
+
auto __promise = Promise<void>::create();
|
|
181
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
182
|
+
__promise->resolve();
|
|
183
|
+
});
|
|
184
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
185
|
+
jni::JniException __jniError(__throwable);
|
|
186
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
187
|
+
});
|
|
188
|
+
return __promise;
|
|
189
|
+
}();
|
|
190
|
+
}
|
|
191
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::closeChat() {
|
|
192
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("closeChat");
|
|
193
|
+
auto __result = method(_javaPart);
|
|
194
|
+
return [&]() {
|
|
195
|
+
auto __promise = Promise<void>::create();
|
|
196
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
197
|
+
__promise->resolve();
|
|
198
|
+
});
|
|
199
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
200
|
+
jni::JniException __jniError(__throwable);
|
|
201
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
202
|
+
});
|
|
203
|
+
return __promise;
|
|
204
|
+
}();
|
|
205
|
+
}
|
|
206
|
+
void JHybridCarrotQuestSpec::onChatVisibilityChanged(const std::function<void(bool /* visible */)>& listener) {
|
|
207
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* listener */)>("onChatVisibilityChanged_cxx");
|
|
208
|
+
method(_javaPart, JFunc_void_bool_cxx::fromCpp(listener));
|
|
209
|
+
}
|
|
210
|
+
void JHybridCarrotQuestSpec::setTheme(CarrotQuestTheme theme) {
|
|
211
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JCarrotQuestTheme> /* theme */)>("setTheme");
|
|
212
|
+
method(_javaPart, JCarrotQuestTheme::fromCpp(theme));
|
|
213
|
+
}
|
|
214
|
+
std::shared_ptr<Promise<double>> JHybridCarrotQuestSpec::getUnreadConversationsCount() {
|
|
215
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getUnreadConversationsCount");
|
|
216
|
+
auto __result = method(_javaPart);
|
|
217
|
+
return [&]() {
|
|
218
|
+
auto __promise = Promise<double>::create();
|
|
219
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
220
|
+
auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
|
|
221
|
+
__promise->resolve(__result->value());
|
|
222
|
+
});
|
|
223
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
224
|
+
jni::JniException __jniError(__throwable);
|
|
225
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
226
|
+
});
|
|
227
|
+
return __promise;
|
|
228
|
+
}();
|
|
229
|
+
}
|
|
230
|
+
std::shared_ptr<Promise<std::optional<double>>> JHybridCarrotQuestSpec::getUnreadMessagesCount() {
|
|
231
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getUnreadMessagesCount");
|
|
232
|
+
auto __result = method(_javaPart);
|
|
233
|
+
return [&]() {
|
|
234
|
+
auto __promise = Promise<std::optional<double>>::create();
|
|
235
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
236
|
+
auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
|
|
237
|
+
__promise->resolve(__result != nullptr ? std::make_optional(__result->value()) : std::nullopt);
|
|
238
|
+
});
|
|
239
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
240
|
+
jni::JniException __jniError(__throwable);
|
|
241
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
242
|
+
});
|
|
243
|
+
return __promise;
|
|
244
|
+
}();
|
|
245
|
+
}
|
|
246
|
+
void JHybridCarrotQuestSpec::onUnreadConversationsChanged(const std::function<void(double /* count */)>& listener) {
|
|
247
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* listener */)>("onUnreadConversationsChanged_cxx");
|
|
248
|
+
method(_javaPart, JFunc_void_double_cxx::fromCpp(listener));
|
|
249
|
+
}
|
|
250
|
+
void JHybridCarrotQuestSpec::setUserProperties(const CarrotQuestUserProperties& properties) {
|
|
251
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JCarrotQuestUserProperties> /* properties */)>("setUserProperties");
|
|
252
|
+
method(_javaPart, JCarrotQuestUserProperties::fromCpp(properties));
|
|
253
|
+
}
|
|
254
|
+
void JHybridCarrotQuestSpec::setProperties(const std::vector<CarrotQuestProperty>& properties) {
|
|
255
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JCarrotQuestProperty>> /* properties */)>("setProperties");
|
|
256
|
+
method(_javaPart, [&](auto&& __input) {
|
|
257
|
+
size_t __size = __input.size();
|
|
258
|
+
jni::local_ref<jni::JArrayClass<JCarrotQuestProperty>> __array = jni::JArrayClass<JCarrotQuestProperty>::newArray(__size);
|
|
259
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
260
|
+
const auto& __element = __input[__i];
|
|
261
|
+
auto __elementJni = JCarrotQuestProperty::fromCpp(__element);
|
|
262
|
+
__array->setElement(__i, *__elementJni);
|
|
263
|
+
}
|
|
264
|
+
return __array;
|
|
265
|
+
}(properties));
|
|
266
|
+
}
|
|
267
|
+
void JHybridCarrotQuestSpec::trackEvent(const std::string& name, const std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>>& params) {
|
|
268
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JMap<jni::JString, JCarrotQuestEventValue>> /* params */)>("trackEvent");
|
|
269
|
+
method(_javaPart, jni::make_jstring(name), params.has_value() ? [&]() -> jni::local_ref<jni::JMap<jni::JString, JCarrotQuestEventValue>> {
|
|
270
|
+
auto __map = jni::JHashMap<jni::JString, JCarrotQuestEventValue>::create(params.value().size());
|
|
271
|
+
for (const auto& __entry : params.value()) {
|
|
272
|
+
__map->put(jni::make_jstring(__entry.first), JCarrotQuestEventValue::fromCpp(__entry.second));
|
|
273
|
+
}
|
|
274
|
+
return __map;
|
|
275
|
+
}() : nullptr);
|
|
276
|
+
}
|
|
277
|
+
void JHybridCarrotQuestSpec::trackScreen(const std::string& name) {
|
|
278
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */)>("trackScreen");
|
|
279
|
+
method(_javaPart, jni::make_jstring(name));
|
|
280
|
+
}
|
|
281
|
+
void JHybridCarrotQuestSpec::trackUtm(const std::string& url) {
|
|
282
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* url */)>("trackUtm");
|
|
283
|
+
method(_javaPart, jni::make_jstring(url));
|
|
284
|
+
}
|
|
285
|
+
void JHybridCarrotQuestSpec::setPushToken(const std::string& token) {
|
|
286
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* token */)>("setPushToken");
|
|
287
|
+
method(_javaPart, jni::make_jstring(token));
|
|
288
|
+
}
|
|
289
|
+
void JHybridCarrotQuestSpec::deletePushToken() {
|
|
290
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("deletePushToken");
|
|
291
|
+
method(_javaPart);
|
|
292
|
+
}
|
|
293
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::pushNotificationsUnsubscribe() {
|
|
294
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pushNotificationsUnsubscribe");
|
|
295
|
+
auto __result = method(_javaPart);
|
|
296
|
+
return [&]() {
|
|
297
|
+
auto __promise = Promise<void>::create();
|
|
298
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
299
|
+
__promise->resolve();
|
|
300
|
+
});
|
|
301
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
302
|
+
jni::JniException __jniError(__throwable);
|
|
303
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
304
|
+
});
|
|
305
|
+
return __promise;
|
|
306
|
+
}();
|
|
307
|
+
}
|
|
308
|
+
std::shared_ptr<Promise<void>> JHybridCarrotQuestSpec::pushCampaignsUnsubscribe() {
|
|
309
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pushCampaignsUnsubscribe");
|
|
310
|
+
auto __result = method(_javaPart);
|
|
311
|
+
return [&]() {
|
|
312
|
+
auto __promise = Promise<void>::create();
|
|
313
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
314
|
+
__promise->resolve();
|
|
315
|
+
});
|
|
316
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
317
|
+
jni::JniException __jniError(__throwable);
|
|
318
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
319
|
+
});
|
|
320
|
+
return __promise;
|
|
321
|
+
}();
|
|
322
|
+
}
|
|
323
|
+
bool JHybridCarrotQuestSpec::isCarrotPush(const std::string& payloadJson) {
|
|
324
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* payloadJson */)>("isCarrotPush");
|
|
325
|
+
auto __result = method(_javaPart, jni::make_jstring(payloadJson));
|
|
326
|
+
return static_cast<bool>(__result);
|
|
327
|
+
}
|
|
328
|
+
bool JHybridCarrotQuestSpec::isAutoMessage(const std::string& payloadJson) {
|
|
329
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* payloadJson */)>("isAutoMessage");
|
|
330
|
+
auto __result = method(_javaPart, jni::make_jstring(payloadJson));
|
|
331
|
+
return static_cast<bool>(__result);
|
|
332
|
+
}
|
|
333
|
+
void JHybridCarrotQuestSpec::handlePushNotification(const std::string& payloadJson) {
|
|
334
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* payloadJson */)>("handlePushNotification");
|
|
335
|
+
method(_javaPart, jni::make_jstring(payloadJson));
|
|
336
|
+
}
|
|
337
|
+
void JHybridCarrotQuestSpec::handlePushClick(const std::string& payloadJson, bool openLink) {
|
|
338
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* payloadJson */, jboolean /* openLink */)>("handlePushClick");
|
|
339
|
+
method(_javaPart, jni::make_jstring(payloadJson), openLink);
|
|
340
|
+
}
|
|
341
|
+
std::optional<std::string> JHybridCarrotQuestSpec::getPushLink(const std::string& payloadJson) {
|
|
342
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>(jni::alias_ref<jni::JString> /* payloadJson */)>("getPushLink");
|
|
343
|
+
auto __result = method(_javaPart, jni::make_jstring(payloadJson));
|
|
344
|
+
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
345
|
+
}
|
|
346
|
+
std::shared_ptr<Promise<bool>> JHybridCarrotQuestSpec::wasPushShownEarlier(const std::string& payloadJson) {
|
|
347
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* payloadJson */)>("wasPushShownEarlier");
|
|
348
|
+
auto __result = method(_javaPart, jni::make_jstring(payloadJson));
|
|
349
|
+
return [&]() {
|
|
350
|
+
auto __promise = Promise<bool>::create();
|
|
351
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
352
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
353
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
354
|
+
});
|
|
355
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
356
|
+
jni::JniException __jniError(__throwable);
|
|
357
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
358
|
+
});
|
|
359
|
+
return __promise;
|
|
360
|
+
}();
|
|
361
|
+
}
|
|
362
|
+
void JHybridCarrotQuestSpec::onUrlOpen(CarrotQuestUrlSource source, const std::function<void(const std::string& /* url */)>& listener) {
|
|
363
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JCarrotQuestUrlSource> /* source */, jni::alias_ref<JFunc_void_std__string::javaobject> /* listener */)>("onUrlOpen_cxx");
|
|
364
|
+
method(_javaPart, JCarrotQuestUrlSource::fromCpp(source), JFunc_void_std__string_cxx::fromCpp(listener));
|
|
365
|
+
}
|
|
366
|
+
void JHybridCarrotQuestSpec::openBrowserLink(const std::string& url) {
|
|
367
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* url */)>("openBrowserLink");
|
|
368
|
+
method(_javaPart, jni::make_jstring(url));
|
|
369
|
+
}
|
|
370
|
+
void JHybridCarrotQuestSpec::openUniversalLink(const std::string& url) {
|
|
371
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* url */)>("openUniversalLink");
|
|
372
|
+
method(_javaPart, jni::make_jstring(url));
|
|
373
|
+
}
|
|
374
|
+
std::optional<std::string> JHybridCarrotQuestSpec::getDiagnostics() {
|
|
375
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getDiagnostics");
|
|
376
|
+
auto __result = method(_javaPart);
|
|
377
|
+
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
378
|
+
}
|
|
379
|
+
void JHybridCarrotQuestSpec::onLog(const std::function<void(const CarrotQuestLogEntry& /* entry */)>& listener) {
|
|
380
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_CarrotQuestLogEntry::javaobject> /* listener */)>("onLog_cxx");
|
|
381
|
+
method(_javaPart, JFunc_void_CarrotQuestLogEntry_cxx::fromCpp(listener));
|
|
382
|
+
}
|
|
383
|
+
void JHybridCarrotQuestSpec::offLog() {
|
|
384
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("offLog");
|
|
385
|
+
method(_javaPart);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
} // namespace margelo::nitro::carrotquest
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCarrotQuestSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridCarrotQuestSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::carrotquest {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridCarrotQuestSpec: public virtual HybridCarrotQuestSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/carrotquest/HybridCarrotQuestSpec;";
|
|
25
|
+
std::shared_ptr<JHybridCarrotQuestSpec> getJHybridCarrotQuestSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/carrotquest/HybridCarrotQuestSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridCarrotQuestSpec(const jni::local_ref<JHybridCarrotQuestSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridCarrotQuestSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridCarrotQuestSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridCarrotQuestSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
bool getIsConfigured() override;
|
|
54
|
+
bool getIsChatOpen() override;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
std::shared_ptr<Promise<void>> setup(const std::string& apiKey, const std::optional<CarrotQuestSetupOptions>& options) override;
|
|
59
|
+
std::string getSdkVersion() override;
|
|
60
|
+
std::shared_ptr<Promise<std::optional<std::string>>> auth(const std::string& userId, const std::string& userAuthKey) override;
|
|
61
|
+
std::shared_ptr<Promise<std::optional<std::string>>> hashedAuth(const std::string& userId, const std::string& hash) override;
|
|
62
|
+
std::shared_ptr<Promise<void>> logout() override;
|
|
63
|
+
std::shared_ptr<Promise<void>> openChat() override;
|
|
64
|
+
std::shared_ptr<Promise<void>> closeChat() override;
|
|
65
|
+
void onChatVisibilityChanged(const std::function<void(bool /* visible */)>& listener) override;
|
|
66
|
+
void setTheme(CarrotQuestTheme theme) override;
|
|
67
|
+
std::shared_ptr<Promise<double>> getUnreadConversationsCount() override;
|
|
68
|
+
std::shared_ptr<Promise<std::optional<double>>> getUnreadMessagesCount() override;
|
|
69
|
+
void onUnreadConversationsChanged(const std::function<void(double /* count */)>& listener) override;
|
|
70
|
+
void setUserProperties(const CarrotQuestUserProperties& properties) override;
|
|
71
|
+
void setProperties(const std::vector<CarrotQuestProperty>& properties) override;
|
|
72
|
+
void trackEvent(const std::string& name, const std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>>& params) override;
|
|
73
|
+
void trackScreen(const std::string& name) override;
|
|
74
|
+
void trackUtm(const std::string& url) override;
|
|
75
|
+
void setPushToken(const std::string& token) override;
|
|
76
|
+
void deletePushToken() override;
|
|
77
|
+
std::shared_ptr<Promise<void>> pushNotificationsUnsubscribe() override;
|
|
78
|
+
std::shared_ptr<Promise<void>> pushCampaignsUnsubscribe() override;
|
|
79
|
+
bool isCarrotPush(const std::string& payloadJson) override;
|
|
80
|
+
bool isAutoMessage(const std::string& payloadJson) override;
|
|
81
|
+
void handlePushNotification(const std::string& payloadJson) override;
|
|
82
|
+
void handlePushClick(const std::string& payloadJson, bool openLink) override;
|
|
83
|
+
std::optional<std::string> getPushLink(const std::string& payloadJson) override;
|
|
84
|
+
std::shared_ptr<Promise<bool>> wasPushShownEarlier(const std::string& payloadJson) override;
|
|
85
|
+
void onUrlOpen(CarrotQuestUrlSource source, const std::function<void(const std::string& /* url */)>& listener) override;
|
|
86
|
+
void openBrowserLink(const std::string& url) override;
|
|
87
|
+
void openUniversalLink(const std::string& url) override;
|
|
88
|
+
std::optional<std::string> getDiagnostics() override;
|
|
89
|
+
void onLog(const std::function<void(const CarrotQuestLogEntry& /* entry */)>& listener) override;
|
|
90
|
+
void offLog() override;
|
|
91
|
+
|
|
92
|
+
private:
|
|
93
|
+
jni::global_ref<JHybridCarrotQuestSpec::JavaPart> _javaPart;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro::carrotquest
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#
|
|
2
|
+
# carrotquest+autolinking.cmake
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © 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/carrotquest+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_CARROTQUEST_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
|
+
carrotquest PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/carrotquestOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridCarrotQuestSpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridCarrotQuestSpec.cpp
|
|
39
|
+
../nitrogen/generated/android/c++/JCarrotQuestEventValue.cpp
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
43
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
44
|
+
target_compile_definitions(
|
|
45
|
+
carrotquest PRIVATE
|
|
46
|
+
-DFOLLY_NO_CONFIG=1
|
|
47
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
48
|
+
-DFOLLY_USE_LIBCPP=1
|
|
49
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
50
|
+
-DFOLLY_MOBILE=1
|
|
51
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
52
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
53
|
+
# Once we target android-23 above, we can comment
|
|
54
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
55
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Add all libraries required by the generated specs
|
|
59
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
60
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
61
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
62
|
+
|
|
63
|
+
# Link all libraries together
|
|
64
|
+
target_link_libraries(
|
|
65
|
+
carrotquest
|
|
66
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
67
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
68
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
72
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
73
|
+
target_link_libraries(
|
|
74
|
+
carrotquest
|
|
75
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
76
|
+
)
|
|
77
|
+
else()
|
|
78
|
+
target_link_libraries(
|
|
79
|
+
carrotquest
|
|
80
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
81
|
+
)
|
|
82
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// carrotquest+autolinking.gradle
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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/carrotquest+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 carrotquest 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,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// carrotquestOnLoad.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#ifndef BUILDING_CARROTQUEST_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error carrotquestOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "carrotquestOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridCarrotQuestSpec.hpp"
|
|
19
|
+
#include "JFunc_void_bool.hpp"
|
|
20
|
+
#include "JFunc_void_double.hpp"
|
|
21
|
+
#include "JFunc_void_std__string.hpp"
|
|
22
|
+
#include "JFunc_void_CarrotQuestLogEntry.hpp"
|
|
23
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::carrotquest {
|
|
26
|
+
|
|
27
|
+
int initialize(JavaVM* vm) {
|
|
28
|
+
return facebook::jni::initialize(vm, []() {
|
|
29
|
+
::margelo::nitro::carrotquest::registerAllNatives();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
struct JHybridCarrotQuestSpecImpl: public jni::JavaClass<JHybridCarrotQuestSpecImpl, JHybridCarrotQuestSpec::JavaPart> {
|
|
34
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/carrotquest/CarrotQuest;";
|
|
35
|
+
static std::shared_ptr<JHybridCarrotQuestSpec> create() {
|
|
36
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridCarrotQuestSpecImpl::javaobject()>();
|
|
37
|
+
jni::local_ref<JHybridCarrotQuestSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
38
|
+
return javaPart->getJHybridCarrotQuestSpec();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
void registerAllNatives() {
|
|
43
|
+
using namespace margelo::nitro;
|
|
44
|
+
using namespace margelo::nitro::carrotquest;
|
|
45
|
+
|
|
46
|
+
// Register native JNI methods
|
|
47
|
+
margelo::nitro::carrotquest::JHybridCarrotQuestSpec::CxxPart::registerNatives();
|
|
48
|
+
margelo::nitro::carrotquest::JFunc_void_bool_cxx::registerNatives();
|
|
49
|
+
margelo::nitro::carrotquest::JFunc_void_double_cxx::registerNatives();
|
|
50
|
+
margelo::nitro::carrotquest::JFunc_void_std__string_cxx::registerNatives();
|
|
51
|
+
margelo::nitro::carrotquest::JFunc_void_CarrotQuestLogEntry_cxx::registerNatives();
|
|
52
|
+
|
|
53
|
+
// Register Nitro Hybrid Objects
|
|
54
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
55
|
+
"CarrotQuest",
|
|
56
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
57
|
+
return JHybridCarrotQuestSpecImpl::create();
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::carrotquest
|