react-native-push-signal 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/LICENSE +20 -0
- package/PushSignal.podspec +31 -0
- package/README.md +125 -0
- package/README.ru.md +125 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +115 -0
- package/android/src/main/AndroidManifest.xml +18 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +44 -0
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +353 -0
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalInitProvider.kt +34 -0
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalMessagingService.kt +15 -0
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalPackage.kt +22 -0
- package/ios/PushSignal.swift +38 -0
- package/ios/PushSignalCenter.swift +430 -0
- package/ios/PushSignalLaunchStore.h +21 -0
- package/ios/PushSignalLaunchStore.m +26 -0
- package/lib/module/PushSignal.nitro.js +4 -0
- package/lib/module/PushSignal.nitro.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/pushSignal.js +19 -0
- package/lib/module/pushSignal.js.map +1 -0
- package/lib/module/pushSignal.native.js +46 -0
- package/lib/module/pushSignal.native.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/PushSignal.nitro.d.ts +33 -0
- package/lib/typescript/src/PushSignal.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/pushSignal.d.ts +8 -0
- package/lib/typescript/src/pushSignal.d.ts.map +1 -0
- package/lib/typescript/src/pushSignal.native.d.ts +8 -0
- package/lib/typescript/src/pushSignal.native.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JAndroidFirebaseConfig.hpp +70 -0
- package/nitrogen/generated/android/c++/JFunc_void_PushMessage.hpp +80 -0
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +138 -0
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JPushCredentials.hpp +70 -0
- package/nitrogen/generated/android/c++/JPushEnvironment.hpp +58 -0
- package/nitrogen/generated/android/c++/JPushMessage.hpp +84 -0
- package/nitrogen/generated/android/c++/JPushPlatform.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_void_PushMessage.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +87 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PermissionStatus.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushCredentials.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushEnvironment.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushMessage.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/pushsignalOnLoad.kt +35 -0
- package/nitrogen/generated/android/pushsignal+autolinking.cmake +81 -0
- package/nitrogen/generated/android/pushsignal+autolinking.gradle +27 -0
- package/nitrogen/generated/android/pushsignalOnLoad.cpp +56 -0
- package/nitrogen/generated/android/pushsignalOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/PushSignal+autolinking.rb +62 -0
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +257 -0
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +66 -0
- package/nitrogen/generated/ios/PushSignalAutolinking.mm +33 -0
- package/nitrogen/generated/ios/PushSignalAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +137 -0
- package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +96 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PushCredentials.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PushMessage.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +226 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
- package/nitrogen/generated/ios/swift/PushCredentials.swift +45 -0
- package/nitrogen/generated/ios/swift/PushEnvironment.swift +40 -0
- package/nitrogen/generated/ios/swift/PushMessage.swift +97 -0
- package/nitrogen/generated/ios/swift/PushPlatform.swift +40 -0
- package/nitrogen/generated/shared/c++/AndroidFirebaseConfig.hpp +96 -0
- package/nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +79 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
- package/nitrogen/generated/shared/c++/PushCredentials.hpp +97 -0
- package/nitrogen/generated/shared/c++/PushEnvironment.hpp +76 -0
- package/nitrogen/generated/shared/c++/PushMessage.hpp +97 -0
- package/nitrogen/generated/shared/c++/PushPlatform.hpp +76 -0
- package/package.json +187 -0
- package/src/PushSignal.nitro.ts +37 -0
- package/src/index.tsx +16 -0
- package/src/pushSignal.native.tsx +67 -0
- package/src/pushSignal.tsx +32 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAndroidFirebaseConfig.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "AndroidFirebaseConfig.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::pushsignal {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "AndroidFirebaseConfig" and the Kotlin data class "AndroidFirebaseConfig".
|
|
22
|
+
*/
|
|
23
|
+
struct JAndroidFirebaseConfig final: public jni::JavaClass<JAndroidFirebaseConfig> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/AndroidFirebaseConfig;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct AndroidFirebaseConfig by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
AndroidFirebaseConfig toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldProjectId = clazz->getField<jni::JString>("projectId");
|
|
36
|
+
jni::local_ref<jni::JString> projectId = this->getFieldValue(fieldProjectId);
|
|
37
|
+
static const auto fieldApplicationId = clazz->getField<jni::JString>("applicationId");
|
|
38
|
+
jni::local_ref<jni::JString> applicationId = this->getFieldValue(fieldApplicationId);
|
|
39
|
+
static const auto fieldApiKey = clazz->getField<jni::JString>("apiKey");
|
|
40
|
+
jni::local_ref<jni::JString> apiKey = this->getFieldValue(fieldApiKey);
|
|
41
|
+
static const auto fieldGcmSenderId = clazz->getField<jni::JString>("gcmSenderId");
|
|
42
|
+
jni::local_ref<jni::JString> gcmSenderId = this->getFieldValue(fieldGcmSenderId);
|
|
43
|
+
return AndroidFirebaseConfig(
|
|
44
|
+
projectId != nullptr ? std::make_optional(projectId->toStdString()) : std::nullopt,
|
|
45
|
+
applicationId != nullptr ? std::make_optional(applicationId->toStdString()) : std::nullopt,
|
|
46
|
+
apiKey != nullptr ? std::make_optional(apiKey->toStdString()) : std::nullopt,
|
|
47
|
+
gcmSenderId != nullptr ? std::make_optional(gcmSenderId->toStdString()) : std::nullopt
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
/**
|
|
53
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
54
|
+
*/
|
|
55
|
+
[[maybe_unused]]
|
|
56
|
+
static jni::local_ref<JAndroidFirebaseConfig::javaobject> fromCpp(const AndroidFirebaseConfig& value) {
|
|
57
|
+
using JSignature = JAndroidFirebaseConfig(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
58
|
+
static const auto clazz = javaClassStatic();
|
|
59
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
60
|
+
return create(
|
|
61
|
+
clazz,
|
|
62
|
+
value.projectId.has_value() ? jni::make_jstring(value.projectId.value()) : nullptr,
|
|
63
|
+
value.applicationId.has_value() ? jni::make_jstring(value.applicationId.value()) : nullptr,
|
|
64
|
+
value.apiKey.has_value() ? jni::make_jstring(value.apiKey.value()) : nullptr,
|
|
65
|
+
value.gcmSenderId.has_value() ? jni::make_jstring(value.gcmSenderId.value()) : nullptr
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_PushMessage.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 <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include "PushMessage.hpp"
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
#include "JPushMessage.hpp"
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <optional>
|
|
19
|
+
#include <unordered_map>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::pushsignal {
|
|
22
|
+
|
|
23
|
+
using namespace facebook;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Represents the Java/Kotlin callback `(message: PushMessage) -> Unit`.
|
|
27
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
28
|
+
*/
|
|
29
|
+
struct JFunc_void_PushMessage: public jni::JavaClass<JFunc_void_PushMessage> {
|
|
30
|
+
public:
|
|
31
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_void_PushMessage;";
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* Invokes the function this `JFunc_void_PushMessage` instance holds through JNI.
|
|
36
|
+
*/
|
|
37
|
+
void invoke(const PushMessage& message) const {
|
|
38
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JPushMessage> /* message */)>("invoke");
|
|
39
|
+
method(self(), JPushMessage::fromCpp(message));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* An implementation of Func_void_PushMessage that is backed by a C++ implementation (using `std::function<...>`)
|
|
45
|
+
*/
|
|
46
|
+
class JFunc_void_PushMessage_cxx final: public jni::HybridClass<JFunc_void_PushMessage_cxx, JFunc_void_PushMessage> {
|
|
47
|
+
public:
|
|
48
|
+
static jni::local_ref<JFunc_void_PushMessage::javaobject> fromCpp(const std::function<void(const PushMessage& /* message */)>& func) {
|
|
49
|
+
return JFunc_void_PushMessage_cxx::newObjectCxxArgs(func);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
/**
|
|
54
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_PushMessage_cxx` instance holds.
|
|
55
|
+
*/
|
|
56
|
+
void invoke_cxx(jni::alias_ref<JPushMessage> message) {
|
|
57
|
+
_func(message->toCpp());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
[[nodiscard]]
|
|
62
|
+
inline const std::function<void(const PushMessage& /* message */)>& getFunction() const {
|
|
63
|
+
return _func;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_void_PushMessage_cxx;";
|
|
68
|
+
static void registerNatives() {
|
|
69
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_PushMessage_cxx::invoke_cxx)});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
explicit JFunc_void_PushMessage_cxx(const std::function<void(const PushMessage& /* message */)>& func): _func(func) { }
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
friend HybridBase;
|
|
77
|
+
std::function<void(const PushMessage& /* message */)> _func;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridPushSignalSpec.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 "JHybridPushSignalSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
12
|
+
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
14
|
+
// Forward declaration of `PushPlatform` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::pushsignal { enum class PushPlatform; }
|
|
16
|
+
// Forward declaration of `PushEnvironment` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::pushsignal { enum class PushEnvironment; }
|
|
18
|
+
// Forward declaration of `AndroidFirebaseConfig` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
|
|
20
|
+
// Forward declaration of `PushMessage` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
22
|
+
|
|
23
|
+
#include "PermissionStatus.hpp"
|
|
24
|
+
#include <NitroModules/Promise.hpp>
|
|
25
|
+
#include <NitroModules/JPromise.hpp>
|
|
26
|
+
#include "JPermissionStatus.hpp"
|
|
27
|
+
#include "PushCredentials.hpp"
|
|
28
|
+
#include "JPushCredentials.hpp"
|
|
29
|
+
#include "PushPlatform.hpp"
|
|
30
|
+
#include "JPushPlatform.hpp"
|
|
31
|
+
#include <string>
|
|
32
|
+
#include "PushEnvironment.hpp"
|
|
33
|
+
#include <optional>
|
|
34
|
+
#include "JPushEnvironment.hpp"
|
|
35
|
+
#include "AndroidFirebaseConfig.hpp"
|
|
36
|
+
#include "JAndroidFirebaseConfig.hpp"
|
|
37
|
+
#include "PushMessage.hpp"
|
|
38
|
+
#include <functional>
|
|
39
|
+
#include "JFunc_void_PushMessage.hpp"
|
|
40
|
+
#include <NitroModules/JNICallable.hpp>
|
|
41
|
+
#include "JPushMessage.hpp"
|
|
42
|
+
#include <unordered_map>
|
|
43
|
+
|
|
44
|
+
namespace margelo::nitro::pushsignal {
|
|
45
|
+
|
|
46
|
+
std::shared_ptr<JHybridPushSignalSpec> JHybridPushSignalSpec::JavaPart::getJHybridPushSignalSpec() {
|
|
47
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
48
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridPushSignalSpec>(hybridObject);
|
|
49
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
50
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridPushSignalSpec!");
|
|
51
|
+
}
|
|
52
|
+
return castHybridObject;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
jni::local_ref<JHybridPushSignalSpec::CxxPart::jhybriddata> JHybridPushSignalSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
56
|
+
return makeCxxInstance(jThis);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
std::shared_ptr<JHybridObject> JHybridPushSignalSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
60
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridPushSignalSpec::JavaPart>(javaPart);
|
|
61
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
62
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridPushSignalSpec::JavaPart!");
|
|
63
|
+
}
|
|
64
|
+
return std::make_shared<JHybridPushSignalSpec>(castJavaPart);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void JHybridPushSignalSpec::CxxPart::registerNatives() {
|
|
68
|
+
registerHybrid({
|
|
69
|
+
makeNativeMethod("initHybrid", JHybridPushSignalSpec::CxxPart::initHybrid),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Properties
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Methods
|
|
77
|
+
void JHybridPushSignalSpec::initialize(const AndroidFirebaseConfig& config) {
|
|
78
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAndroidFirebaseConfig> /* config */)>("initialize");
|
|
79
|
+
method(_javaPart, JAndroidFirebaseConfig::fromCpp(config));
|
|
80
|
+
}
|
|
81
|
+
std::shared_ptr<Promise<PermissionStatus>> JHybridPushSignalSpec::getPermissionStatus() {
|
|
82
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getPermissionStatus");
|
|
83
|
+
auto __result = method(_javaPart);
|
|
84
|
+
return [&]() {
|
|
85
|
+
auto __promise = Promise<PermissionStatus>::create();
|
|
86
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
87
|
+
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
88
|
+
__promise->resolve(__result->toCpp());
|
|
89
|
+
});
|
|
90
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
91
|
+
jni::JniException __jniError(__throwable);
|
|
92
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
93
|
+
});
|
|
94
|
+
return __promise;
|
|
95
|
+
}();
|
|
96
|
+
}
|
|
97
|
+
std::shared_ptr<Promise<PermissionStatus>> JHybridPushSignalSpec::requestPermission() {
|
|
98
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestPermission");
|
|
99
|
+
auto __result = method(_javaPart);
|
|
100
|
+
return [&]() {
|
|
101
|
+
auto __promise = Promise<PermissionStatus>::create();
|
|
102
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
103
|
+
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
104
|
+
__promise->resolve(__result->toCpp());
|
|
105
|
+
});
|
|
106
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
107
|
+
jni::JniException __jniError(__throwable);
|
|
108
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
109
|
+
});
|
|
110
|
+
return __promise;
|
|
111
|
+
}();
|
|
112
|
+
}
|
|
113
|
+
std::shared_ptr<Promise<PushCredentials>> JHybridPushSignalSpec::getCredentials() {
|
|
114
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getCredentials");
|
|
115
|
+
auto __result = method(_javaPart);
|
|
116
|
+
return [&]() {
|
|
117
|
+
auto __promise = Promise<PushCredentials>::create();
|
|
118
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
119
|
+
auto __result = jni::static_ref_cast<JPushCredentials>(__boxedResult);
|
|
120
|
+
__promise->resolve(__result->toCpp());
|
|
121
|
+
});
|
|
122
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
123
|
+
jni::JniException __jniError(__throwable);
|
|
124
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
125
|
+
});
|
|
126
|
+
return __promise;
|
|
127
|
+
}();
|
|
128
|
+
}
|
|
129
|
+
void JHybridPushSignalSpec::setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) {
|
|
130
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PushMessage::javaobject> /* callback */)>("setOnMessage_cxx");
|
|
131
|
+
method(_javaPart, JFunc_void_PushMessage_cxx::fromCpp(callback));
|
|
132
|
+
}
|
|
133
|
+
void JHybridPushSignalSpec::setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) {
|
|
134
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PushMessage::javaobject> /* callback */)>("setOnNotificationPress_cxx");
|
|
135
|
+
method(_javaPart, JFunc_void_PushMessage_cxx::fromCpp(callback));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPushSignalSpec.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 "HybridPushSignalSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::pushsignal {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridPushSignalSpec: public virtual HybridPushSignalSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/HybridPushSignalSpec;";
|
|
25
|
+
std::shared_ptr<JHybridPushSignalSpec> getJHybridPushSignalSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/HybridPushSignalSpec$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 JHybridPushSignalSpec(const jni::local_ref<JHybridPushSignalSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridPushSignalSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridPushSignalSpec() 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<JHybridPushSignalSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
void initialize(const AndroidFirebaseConfig& config) override;
|
|
58
|
+
std::shared_ptr<Promise<PermissionStatus>> getPermissionStatus() override;
|
|
59
|
+
std::shared_ptr<Promise<PermissionStatus>> requestPermission() override;
|
|
60
|
+
std::shared_ptr<Promise<PushCredentials>> getCredentials() override;
|
|
61
|
+
void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) override;
|
|
62
|
+
void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) override;
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
jni::global_ref<JHybridPushSignalSpec::JavaPart> _javaPart;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPermissionStatus.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "PermissionStatus.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::pushsignal {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "PermissionStatus" and the Kotlin enum "PermissionStatus".
|
|
19
|
+
*/
|
|
20
|
+
struct JPermissionStatus final: public jni::JavaClass<JPermissionStatus> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PermissionStatus;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum PermissionStatus.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
PermissionStatus toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<PermissionStatus>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JPermissionStatus> fromCpp(PermissionStatus value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case PermissionStatus::AUTHORIZED:
|
|
46
|
+
static const auto fieldAUTHORIZED = clazz->getStaticField<JPermissionStatus>("AUTHORIZED");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldAUTHORIZED);
|
|
48
|
+
case PermissionStatus::DENIED:
|
|
49
|
+
static const auto fieldDENIED = clazz->getStaticField<JPermissionStatus>("DENIED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldDENIED);
|
|
51
|
+
case PermissionStatus::NOTDETERMINED:
|
|
52
|
+
static const auto fieldNOTDETERMINED = clazz->getStaticField<JPermissionStatus>("NOTDETERMINED");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldNOTDETERMINED);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPushCredentials.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "PushCredentials.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JPushEnvironment.hpp"
|
|
14
|
+
#include "JPushPlatform.hpp"
|
|
15
|
+
#include "PushEnvironment.hpp"
|
|
16
|
+
#include "PushPlatform.hpp"
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::pushsignal {
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ JNI bridge between the C++ struct "PushCredentials" and the Kotlin data class "PushCredentials".
|
|
26
|
+
*/
|
|
27
|
+
struct JPushCredentials final: public jni::JavaClass<JPushCredentials> {
|
|
28
|
+
public:
|
|
29
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PushCredentials;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Convert this Java/Kotlin-based struct to the C++ struct PushCredentials by copying all values to C++.
|
|
34
|
+
*/
|
|
35
|
+
[[maybe_unused]]
|
|
36
|
+
[[nodiscard]]
|
|
37
|
+
PushCredentials toCpp() const {
|
|
38
|
+
static const auto clazz = javaClassStatic();
|
|
39
|
+
static const auto fieldPlatform = clazz->getField<JPushPlatform>("platform");
|
|
40
|
+
jni::local_ref<JPushPlatform> platform = this->getFieldValue(fieldPlatform);
|
|
41
|
+
static const auto fieldToken = clazz->getField<jni::JString>("token");
|
|
42
|
+
jni::local_ref<jni::JString> token = this->getFieldValue(fieldToken);
|
|
43
|
+
static const auto fieldEnvironment = clazz->getField<JPushEnvironment>("environment");
|
|
44
|
+
jni::local_ref<JPushEnvironment> environment = this->getFieldValue(fieldEnvironment);
|
|
45
|
+
return PushCredentials(
|
|
46
|
+
platform->toCpp(),
|
|
47
|
+
token->toStdString(),
|
|
48
|
+
environment != nullptr ? std::make_optional(environment->toCpp()) : std::nullopt
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
/**
|
|
54
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
55
|
+
*/
|
|
56
|
+
[[maybe_unused]]
|
|
57
|
+
static jni::local_ref<JPushCredentials::javaobject> fromCpp(const PushCredentials& value) {
|
|
58
|
+
using JSignature = JPushCredentials(jni::alias_ref<JPushPlatform>, jni::alias_ref<jni::JString>, jni::alias_ref<JPushEnvironment>);
|
|
59
|
+
static const auto clazz = javaClassStatic();
|
|
60
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
61
|
+
return create(
|
|
62
|
+
clazz,
|
|
63
|
+
JPushPlatform::fromCpp(value.platform),
|
|
64
|
+
jni::make_jstring(value.token),
|
|
65
|
+
value.environment.has_value() ? JPushEnvironment::fromCpp(value.environment.value()) : nullptr
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPushEnvironment.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "PushEnvironment.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::pushsignal {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "PushEnvironment" and the Kotlin enum "PushEnvironment".
|
|
19
|
+
*/
|
|
20
|
+
struct JPushEnvironment final: public jni::JavaClass<JPushEnvironment> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PushEnvironment;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum PushEnvironment.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
PushEnvironment toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<PushEnvironment>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JPushEnvironment> fromCpp(PushEnvironment value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case PushEnvironment::SANDBOX:
|
|
46
|
+
static const auto fieldSANDBOX = clazz->getStaticField<JPushEnvironment>("SANDBOX");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldSANDBOX);
|
|
48
|
+
case PushEnvironment::PRODUCTION:
|
|
49
|
+
static const auto fieldPRODUCTION = clazz->getStaticField<JPushEnvironment>("PRODUCTION");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldPRODUCTION);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPushMessage.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 <fbjni/fbjni.h>
|
|
11
|
+
#include "PushMessage.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <unordered_map>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::pushsignal {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ struct "PushMessage" and the Kotlin data class "PushMessage".
|
|
23
|
+
*/
|
|
24
|
+
struct JPushMessage final: public jni::JavaClass<JPushMessage> {
|
|
25
|
+
public:
|
|
26
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PushMessage;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Convert this Java/Kotlin-based struct to the C++ struct PushMessage by copying all values to C++.
|
|
31
|
+
*/
|
|
32
|
+
[[maybe_unused]]
|
|
33
|
+
[[nodiscard]]
|
|
34
|
+
PushMessage toCpp() const {
|
|
35
|
+
static const auto clazz = javaClassStatic();
|
|
36
|
+
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
37
|
+
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
38
|
+
static const auto fieldTitle = clazz->getField<jni::JString>("title");
|
|
39
|
+
jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
|
|
40
|
+
static const auto fieldBody = clazz->getField<jni::JString>("body");
|
|
41
|
+
jni::local_ref<jni::JString> body = this->getFieldValue(fieldBody);
|
|
42
|
+
static const auto fieldData = clazz->getField<jni::JMap<jni::JString, jni::JString>>("data");
|
|
43
|
+
jni::local_ref<jni::JMap<jni::JString, jni::JString>> data = this->getFieldValue(fieldData);
|
|
44
|
+
return PushMessage(
|
|
45
|
+
id != nullptr ? std::make_optional(id->toStdString()) : std::nullopt,
|
|
46
|
+
title != nullptr ? std::make_optional(title->toStdString()) : std::nullopt,
|
|
47
|
+
body != nullptr ? std::make_optional(body->toStdString()) : std::nullopt,
|
|
48
|
+
[&]() {
|
|
49
|
+
std::unordered_map<std::string, std::string> __map;
|
|
50
|
+
__map.reserve(data->size());
|
|
51
|
+
for (const auto& __entry : *data) {
|
|
52
|
+
__map.emplace(__entry.first->toStdString(), __entry.second->toStdString());
|
|
53
|
+
}
|
|
54
|
+
return __map;
|
|
55
|
+
}()
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
/**
|
|
61
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
62
|
+
*/
|
|
63
|
+
[[maybe_unused]]
|
|
64
|
+
static jni::local_ref<JPushMessage::javaobject> fromCpp(const PushMessage& value) {
|
|
65
|
+
using JSignature = JPushMessage(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>);
|
|
66
|
+
static const auto clazz = javaClassStatic();
|
|
67
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
68
|
+
return create(
|
|
69
|
+
clazz,
|
|
70
|
+
value.id.has_value() ? jni::make_jstring(value.id.value()) : nullptr,
|
|
71
|
+
value.title.has_value() ? jni::make_jstring(value.title.value()) : nullptr,
|
|
72
|
+
value.body.has_value() ? jni::make_jstring(value.body.value()) : nullptr,
|
|
73
|
+
[&]() -> jni::local_ref<jni::JMap<jni::JString, jni::JString>> {
|
|
74
|
+
auto __map = jni::JHashMap<jni::JString, jni::JString>::create(value.data.size());
|
|
75
|
+
for (const auto& __entry : value.data) {
|
|
76
|
+
__map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second));
|
|
77
|
+
}
|
|
78
|
+
return __map;
|
|
79
|
+
}()
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::pushsignal
|