react-native-push-signal 0.1.4 → 0.1.6
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/README.md +2 -8
- package/README.ru.md +2 -8
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +23 -69
- package/ios/PushSignal.swift +1 -1
- package/ios/PushSignalCenter.swift +89 -73
- package/ios/PushSignalLaunchStore.m +11 -3
- package/lib/module/pushSignal.native.js +5 -7
- package/lib/module/pushSignal.native.js.map +1 -1
- package/lib/typescript/src/PushSignal.nitro.d.ts +2 -2
- package/lib/typescript/src/PushSignal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/pushSignal.native.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +4 -5
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +2 -2
- package/nitrogen/generated/android/pushsignalOnLoad.cpp +0 -2
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +0 -25
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +0 -91
- package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +5 -26
- package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +1 -1
- package/package.json +1 -1
- package/src/PushSignal.nitro.ts +2 -2
- package/src/pushSignal.native.tsx +8 -13
- package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.hpp +0 -128
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.kt +0 -78
- package/nitrogen/generated/ios/swift/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.swift +0 -61
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_Promise_bool__.swift +0 -66
|
@@ -38,31 +38,6 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// pragma MARK: std::function<void(bool /* result */)>
|
|
42
|
-
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
43
|
-
auto swiftClosure = PushSignal::Func_void_bool::fromUnsafe(swiftClosureWrapper);
|
|
44
|
-
return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
|
|
45
|
-
swiftClosure.call(result);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// pragma MARK: std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>
|
|
50
|
-
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
51
|
-
auto swiftClosure = PushSignal::Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage::fromUnsafe(swiftClosureWrapper);
|
|
52
|
-
return [swiftClosure = std::move(swiftClosure)](const PushMessage& message) mutable -> std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> {
|
|
53
|
-
auto __result = swiftClosure.call(message);
|
|
54
|
-
return __result;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// pragma MARK: std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>
|
|
59
|
-
Func_void_std__shared_ptr_Promise_bool__ create_Func_void_std__shared_ptr_Promise_bool__(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
60
|
-
auto swiftClosure = PushSignal::Func_void_std__shared_ptr_Promise_bool__::fromUnsafe(swiftClosureWrapper);
|
|
61
|
-
return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<Promise<bool>>& result) mutable -> void {
|
|
62
|
-
swiftClosure.call(result);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
41
|
// pragma MARK: std::function<void(const PushMessage& /* message */)>
|
|
67
42
|
Func_void_PushMessage create_Func_void_PushMessage(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
68
43
|
auto swiftClosure = PushSignal::Func_void_PushMessage::fromUnsafe(swiftClosureWrapper);
|
|
@@ -165,40 +165,6 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
165
165
|
return Func_void_PushCredentials_Wrapper(std::move(value));
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
// pragma MARK: std::shared_ptr<Promise<bool>>
|
|
169
|
-
/**
|
|
170
|
-
* Specialized version of `std::shared_ptr<Promise<bool>>`.
|
|
171
|
-
*/
|
|
172
|
-
using std__shared_ptr_Promise_bool__ = std::shared_ptr<Promise<bool>>;
|
|
173
|
-
inline std::shared_ptr<Promise<bool>> create_std__shared_ptr_Promise_bool__() noexcept {
|
|
174
|
-
return Promise<bool>::create();
|
|
175
|
-
}
|
|
176
|
-
inline PromiseHolder<bool> wrap_std__shared_ptr_Promise_bool__(std::shared_ptr<Promise<bool>> promise) noexcept {
|
|
177
|
-
return PromiseHolder<bool>(std::move(promise));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// pragma MARK: std::function<void(bool /* result */)>
|
|
181
|
-
/**
|
|
182
|
-
* Specialized version of `std::function<void(bool)>`.
|
|
183
|
-
*/
|
|
184
|
-
using Func_void_bool = std::function<void(bool /* result */)>;
|
|
185
|
-
/**
|
|
186
|
-
* Wrapper class for a `std::function<void(bool / * result * /)>`, this can be used from Swift.
|
|
187
|
-
*/
|
|
188
|
-
class Func_void_bool_Wrapper final {
|
|
189
|
-
public:
|
|
190
|
-
explicit Func_void_bool_Wrapper(std::function<void(bool /* result */)>&& func): _function(std::make_unique<std::function<void(bool /* result */)>>(std::move(func))) {}
|
|
191
|
-
inline void call(bool result) const noexcept {
|
|
192
|
-
_function->operator()(result);
|
|
193
|
-
}
|
|
194
|
-
private:
|
|
195
|
-
std::unique_ptr<std::function<void(bool /* result */)>> _function;
|
|
196
|
-
} SWIFT_NONCOPYABLE;
|
|
197
|
-
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
198
|
-
inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
|
|
199
|
-
return Func_void_bool_Wrapper(std::move(value));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
168
|
// pragma MARK: std::unordered_map<std::string, std::string>
|
|
203
169
|
/**
|
|
204
170
|
* Specialized version of `std::unordered_map<std::string, std::string>`.
|
|
@@ -224,63 +190,6 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
224
190
|
map.emplace(key, value);
|
|
225
191
|
}
|
|
226
192
|
|
|
227
|
-
// pragma MARK: std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>
|
|
228
|
-
/**
|
|
229
|
-
* Specialized version of `std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage&)>`.
|
|
230
|
-
*/
|
|
231
|
-
using Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage = std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>;
|
|
232
|
-
/**
|
|
233
|
-
* Wrapper class for a `std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& / * message * /)>`, this can be used from Swift.
|
|
234
|
-
*/
|
|
235
|
-
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_Wrapper final {
|
|
236
|
-
public:
|
|
237
|
-
explicit Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_Wrapper(std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>&& func): _function(std::make_unique<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>>(std::move(func))) {}
|
|
238
|
-
inline std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> call(PushMessage message) const noexcept {
|
|
239
|
-
auto __result = _function->operator()(message);
|
|
240
|
-
return __result;
|
|
241
|
-
}
|
|
242
|
-
private:
|
|
243
|
-
std::unique_ptr<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>> _function;
|
|
244
|
-
} SWIFT_NONCOPYABLE;
|
|
245
|
-
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
246
|
-
inline Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_Wrapper wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage(Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage value) noexcept {
|
|
247
|
-
return Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_Wrapper(std::move(value));
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// pragma MARK: std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>
|
|
251
|
-
/**
|
|
252
|
-
* Specialized version of `std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>`.
|
|
253
|
-
*/
|
|
254
|
-
using std__shared_ptr_Promise_std__shared_ptr_Promise_bool____ = std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>;
|
|
255
|
-
inline std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> create_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____() noexcept {
|
|
256
|
-
return Promise<std::shared_ptr<Promise<bool>>>::create();
|
|
257
|
-
}
|
|
258
|
-
inline PromiseHolder<std::shared_ptr<Promise<bool>>> wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____(std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> promise) noexcept {
|
|
259
|
-
return PromiseHolder<std::shared_ptr<Promise<bool>>>(std::move(promise));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// pragma MARK: std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>
|
|
263
|
-
/**
|
|
264
|
-
* Specialized version of `std::function<void(const std::shared_ptr<Promise<bool>>&)>`.
|
|
265
|
-
*/
|
|
266
|
-
using Func_void_std__shared_ptr_Promise_bool__ = std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>;
|
|
267
|
-
/**
|
|
268
|
-
* Wrapper class for a `std::function<void(const std::shared_ptr<Promise<bool>>& / * result * /)>`, this can be used from Swift.
|
|
269
|
-
*/
|
|
270
|
-
class Func_void_std__shared_ptr_Promise_bool___Wrapper final {
|
|
271
|
-
public:
|
|
272
|
-
explicit Func_void_std__shared_ptr_Promise_bool___Wrapper(std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>>(std::move(func))) {}
|
|
273
|
-
inline void call(std::shared_ptr<Promise<bool>> result) const noexcept {
|
|
274
|
-
_function->operator()(result);
|
|
275
|
-
}
|
|
276
|
-
private:
|
|
277
|
-
std::unique_ptr<std::function<void(const std::shared_ptr<Promise<bool>>& /* result */)>> _function;
|
|
278
|
-
} SWIFT_NONCOPYABLE;
|
|
279
|
-
Func_void_std__shared_ptr_Promise_bool__ create_Func_void_std__shared_ptr_Promise_bool__(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
280
|
-
inline Func_void_std__shared_ptr_Promise_bool___Wrapper wrap_Func_void_std__shared_ptr_Promise_bool__(Func_void_std__shared_ptr_Promise_bool__ value) noexcept {
|
|
281
|
-
return Func_void_std__shared_ptr_Promise_bool___Wrapper(std::move(value));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
193
|
// pragma MARK: std::function<void(const PushMessage& /* message */)>
|
|
285
194
|
/**
|
|
286
195
|
* Specialized version of `std::function<void(const PushMessage&)>`.
|
|
@@ -100,7 +100,7 @@ namespace margelo::nitro::pushsignal {
|
|
|
100
100
|
auto __value = std::move(__result.value());
|
|
101
101
|
return __value;
|
|
102
102
|
}
|
|
103
|
-
inline void setOnMessage(const std::function<
|
|
103
|
+
inline void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) override {
|
|
104
104
|
auto __result = _swiftPart.setOnMessage(callback);
|
|
105
105
|
if (__result.hasError()) [[unlikely]] {
|
|
106
106
|
std::rethrow_exception(__result.error());
|
|
@@ -15,7 +15,7 @@ public protocol HybridPushSignalSpec_protocol: HybridObject {
|
|
|
15
15
|
// Methods
|
|
16
16
|
func initialize(config: AndroidFirebaseConfig) throws -> Promise<Void>
|
|
17
17
|
func getCredentials() throws -> Promise<PushCredentials>
|
|
18
|
-
func setOnMessage(callback: @escaping (_ message: PushMessage) ->
|
|
18
|
+
func setOnMessage(callback: @escaping (_ message: PushMessage) -> Void) throws -> Void
|
|
19
19
|
func setOnNotificationPress(callback: @escaping (_ message: PushMessage) -> Void) throws -> Void
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -163,33 +163,12 @@ open class HybridPushSignalSpec_cxx {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
@inline(__always)
|
|
166
|
-
public final func setOnMessage(callback: bridge.
|
|
166
|
+
public final func setOnMessage(callback: bridge.Func_void_PushMessage) -> bridge.Result_void_ {
|
|
167
167
|
do {
|
|
168
|
-
try self.__implementation.setOnMessage(callback: { () -> (PushMessage) ->
|
|
169
|
-
let __wrappedFunction = bridge.
|
|
170
|
-
return { (__message: PushMessage) ->
|
|
171
|
-
|
|
172
|
-
return { () -> Promise<Promise<Bool>> in
|
|
173
|
-
let __promise = Promise<Promise<Bool>>()
|
|
174
|
-
let __resolver = { (__result: Promise<Bool>) in
|
|
175
|
-
__promise.resolve(withResult: __result)
|
|
176
|
-
}
|
|
177
|
-
let __rejecter = { (__error: Error) in
|
|
178
|
-
__promise.reject(withError: __error)
|
|
179
|
-
}
|
|
180
|
-
let __resolverCpp = { () -> bridge.Func_void_std__shared_ptr_Promise_bool__ in
|
|
181
|
-
let __closureWrapper = Func_void_std__shared_ptr_Promise_bool__(__resolver)
|
|
182
|
-
return bridge.create_Func_void_std__shared_ptr_Promise_bool__(__closureWrapper.toUnsafe())
|
|
183
|
-
}()
|
|
184
|
-
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
185
|
-
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
186
|
-
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
187
|
-
}()
|
|
188
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____(__result)
|
|
189
|
-
__promiseHolder.addOnResolvedListener(__resolverCpp)
|
|
190
|
-
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
191
|
-
return __promise
|
|
192
|
-
}()
|
|
168
|
+
try self.__implementation.setOnMessage(callback: { () -> (PushMessage) -> Void in
|
|
169
|
+
let __wrappedFunction = bridge.wrap_Func_void_PushMessage(callback)
|
|
170
|
+
return { (__message: PushMessage) -> Void in
|
|
171
|
+
__wrappedFunction.call(__message)
|
|
193
172
|
}
|
|
194
173
|
}())
|
|
195
174
|
return bridge.create_Result_void_()
|
|
@@ -59,7 +59,7 @@ namespace margelo::nitro::pushsignal {
|
|
|
59
59
|
// Methods
|
|
60
60
|
virtual std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) = 0;
|
|
61
61
|
virtual std::shared_ptr<Promise<PushCredentials>> getCredentials() = 0;
|
|
62
|
-
virtual void setOnMessage(const std::function<
|
|
62
|
+
virtual void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
|
|
63
63
|
virtual void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
|
|
64
64
|
|
|
65
65
|
protected:
|
package/package.json
CHANGED
package/src/PushSignal.nitro.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface PushMessage {
|
|
|
19
19
|
|
|
20
20
|
export type OnMessageListener = (
|
|
21
21
|
message: PushMessage
|
|
22
|
-
) =>
|
|
22
|
+
) => void | Promise<void>;
|
|
23
23
|
|
|
24
24
|
export interface AndroidFirebaseConfig {
|
|
25
25
|
project_id?: string;
|
|
@@ -34,6 +34,6 @@ export interface PushSignal extends HybridObject<{
|
|
|
34
34
|
}> {
|
|
35
35
|
initialize(config: AndroidFirebaseConfig): Promise<void>;
|
|
36
36
|
getCredentials(): Promise<PushCredentials>;
|
|
37
|
-
setOnMessage(callback: (message: PushMessage) =>
|
|
37
|
+
setOnMessage(callback: (message: PushMessage) => void): void;
|
|
38
38
|
setOnNotificationPress(callback: (message: PushMessage) => void): void;
|
|
39
39
|
}
|
|
@@ -21,19 +21,14 @@ function bindNativeCallbacks() {
|
|
|
21
21
|
|
|
22
22
|
nativeCallbacksBound = true;
|
|
23
23
|
|
|
24
|
-
PushSignalHybridObject.setOnMessage(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return results.some((result) => result === true);
|
|
24
|
+
PushSignalHybridObject.setOnMessage((message) => {
|
|
25
|
+
for (const listener of [...messageListeners]) {
|
|
26
|
+
try {
|
|
27
|
+
void listener(message);
|
|
28
|
+
} catch {
|
|
29
|
+
// Ignore listener failures so one bad subscriber cannot break delivery.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
37
32
|
});
|
|
38
33
|
|
|
39
34
|
PushSignalHybridObject.setOnNotificationPress((message) => {
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____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 <NitroModules/Promise.hpp>
|
|
14
|
-
#include "PushMessage.hpp"
|
|
15
|
-
#include <functional>
|
|
16
|
-
#include <NitroModules/JNICallable.hpp>
|
|
17
|
-
#include <NitroModules/JPromise.hpp>
|
|
18
|
-
#include "JPushMessage.hpp"
|
|
19
|
-
#include <string>
|
|
20
|
-
#include <optional>
|
|
21
|
-
#include <unordered_map>
|
|
22
|
-
|
|
23
|
-
namespace margelo::nitro::pushsignal {
|
|
24
|
-
|
|
25
|
-
using namespace facebook;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Represents the Java/Kotlin callback `(message: PushMessage) -> Promise<Promise<Boolean>>`.
|
|
29
|
-
* This can be passed around between C++ and Java/Kotlin.
|
|
30
|
-
*/
|
|
31
|
-
struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage: public jni::JavaClass<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage> {
|
|
32
|
-
public:
|
|
33
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage;";
|
|
34
|
-
|
|
35
|
-
public:
|
|
36
|
-
/**
|
|
37
|
-
* Invokes the function this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage` instance holds through JNI.
|
|
38
|
-
*/
|
|
39
|
-
std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> invoke(const PushMessage& message) const {
|
|
40
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JPushMessage> /* message */)>("invoke");
|
|
41
|
-
auto __result = method(self(), JPushMessage::fromCpp(message));
|
|
42
|
-
return [&]() {
|
|
43
|
-
auto __promise = Promise<std::shared_ptr<Promise<bool>>>::create();
|
|
44
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
45
|
-
auto __result = jni::static_ref_cast<JPromise::javaobject>(__boxedResult);
|
|
46
|
-
__promise->resolve([&]() {
|
|
47
|
-
auto __promise = Promise<bool>::create();
|
|
48
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
49
|
-
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
50
|
-
__promise->resolve(static_cast<bool>(__result->value()));
|
|
51
|
-
});
|
|
52
|
-
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
53
|
-
jni::JniException __jniError(__throwable);
|
|
54
|
-
__promise->reject(std::make_exception_ptr(__jniError));
|
|
55
|
-
});
|
|
56
|
-
return __promise;
|
|
57
|
-
}());
|
|
58
|
-
});
|
|
59
|
-
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
60
|
-
jni::JniException __jniError(__throwable);
|
|
61
|
-
__promise->reject(std::make_exception_ptr(__jniError));
|
|
62
|
-
});
|
|
63
|
-
return __promise;
|
|
64
|
-
}();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* An implementation of Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage that is backed by a C++ implementation (using `std::function<...>`)
|
|
70
|
-
*/
|
|
71
|
-
class JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx final: public jni::HybridClass<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage> {
|
|
72
|
-
public:
|
|
73
|
-
static jni::local_ref<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage::javaobject> fromCpp(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& func) {
|
|
74
|
-
return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx::newObjectCxxArgs(func);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public:
|
|
78
|
-
/**
|
|
79
|
-
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx` instance holds.
|
|
80
|
-
*/
|
|
81
|
-
jni::local_ref<JPromise::javaobject> invoke_cxx(jni::alias_ref<JPushMessage> message) {
|
|
82
|
-
std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> __result = _func(message->toCpp());
|
|
83
|
-
return [&]() {
|
|
84
|
-
jni::local_ref<JPromise::javaobject> __localPromise = JPromise::create();
|
|
85
|
-
jni::global_ref<JPromise::javaobject> __promise = jni::make_global(__localPromise);
|
|
86
|
-
__result->addOnResolvedListener([=](const std::shared_ptr<Promise<bool>>& __result) {
|
|
87
|
-
__promise->cthis()->resolve([&]() {
|
|
88
|
-
jni::local_ref<JPromise::javaobject> __localPromise = JPromise::create();
|
|
89
|
-
jni::global_ref<JPromise::javaobject> __promise = jni::make_global(__localPromise);
|
|
90
|
-
__result->addOnResolvedListener([=](const bool& __result) {
|
|
91
|
-
__promise->cthis()->resolve(jni::JBoolean::valueOf(__result));
|
|
92
|
-
});
|
|
93
|
-
__result->addOnRejectedListener([=](const std::exception_ptr& __error) {
|
|
94
|
-
auto __jniError = jni::getJavaExceptionForCppException(__error);
|
|
95
|
-
__promise->cthis()->reject(__jniError);
|
|
96
|
-
});
|
|
97
|
-
return __localPromise;
|
|
98
|
-
}());
|
|
99
|
-
});
|
|
100
|
-
__result->addOnRejectedListener([=](const std::exception_ptr& __error) {
|
|
101
|
-
auto __jniError = jni::getJavaExceptionForCppException(__error);
|
|
102
|
-
__promise->cthis()->reject(__jniError);
|
|
103
|
-
});
|
|
104
|
-
return __localPromise;
|
|
105
|
-
}();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public:
|
|
109
|
-
[[nodiscard]]
|
|
110
|
-
inline const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& getFunction() const {
|
|
111
|
-
return _func;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public:
|
|
115
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx;";
|
|
116
|
-
static void registerNatives() {
|
|
117
|
-
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx::invoke_cxx)});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private:
|
|
121
|
-
explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& func): _func(func) { }
|
|
122
|
-
|
|
123
|
-
private:
|
|
124
|
-
friend HybridBase;
|
|
125
|
-
std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)> _func;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
} // namespace margelo::nitro::pushsignal
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.kt
|
|
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
|
-
package com.margelo.nitro.pushsignal
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.jni.HybridData
|
|
12
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import com.margelo.nitro.core.Promise
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Represents the JavaScript callback `(message: struct) => std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>`.
|
|
17
|
-
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
-
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
-
*/
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
@Keep
|
|
22
|
-
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
-
fun interface Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage: (PushMessage) -> Promise<Promise<Boolean>> {
|
|
24
|
-
/**
|
|
25
|
-
* Call the given JS callback.
|
|
26
|
-
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
-
*/
|
|
28
|
-
@DoNotStrip
|
|
29
|
-
@Keep
|
|
30
|
-
override fun invoke(message: PushMessage): Promise<Promise<Boolean>>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Represents the JavaScript callback `(message: struct) => std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>`.
|
|
35
|
-
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
-
* The callback might be coming from JS.
|
|
37
|
-
*/
|
|
38
|
-
@DoNotStrip
|
|
39
|
-
@Keep
|
|
40
|
-
@Suppress(
|
|
41
|
-
"KotlinJniMissingFunction", "unused",
|
|
42
|
-
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
-
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
-
)
|
|
45
|
-
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
46
|
-
@DoNotStrip
|
|
47
|
-
@Keep
|
|
48
|
-
private val mHybridData: HybridData
|
|
49
|
-
|
|
50
|
-
@DoNotStrip
|
|
51
|
-
@Keep
|
|
52
|
-
private constructor(hybridData: HybridData) {
|
|
53
|
-
mHybridData = hybridData
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@DoNotStrip
|
|
57
|
-
@Keep
|
|
58
|
-
override fun invoke(message: PushMessage): Promise<Promise<Boolean>>
|
|
59
|
-
= invoke_cxx(message)
|
|
60
|
-
|
|
61
|
-
private external fun invoke_cxx(message: PushMessage): Promise<Promise<Boolean>>
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Represents the JavaScript callback `(message: struct) => std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>`.
|
|
66
|
-
* This is implemented in Java/Kotlin, via a `(PushMessage) -> Promise<Promise<Boolean>>`.
|
|
67
|
-
* The callback is always coming from native.
|
|
68
|
-
*/
|
|
69
|
-
@DoNotStrip
|
|
70
|
-
@Keep
|
|
71
|
-
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
-
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_java(private val function: (PushMessage) -> Promise<Promise<Boolean>>): Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
73
|
-
@DoNotStrip
|
|
74
|
-
@Keep
|
|
75
|
-
override fun invoke(message: PushMessage): Promise<Promise<Boolean>> {
|
|
76
|
-
return this.function(message)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.swift
|
|
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
|
-
import NitroModules
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Wraps a Swift `(_ message: PushMessage) -> Promise<Promise<Bool>>` as a class.
|
|
12
|
-
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
-
*/
|
|
14
|
-
public final class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
15
|
-
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
-
|
|
17
|
-
private let closure: (_ message: PushMessage) -> Promise<Promise<Bool>>
|
|
18
|
-
|
|
19
|
-
public init(_ closure: @escaping (_ message: PushMessage) -> Promise<Promise<Bool>>) {
|
|
20
|
-
self.closure = closure
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@inline(__always)
|
|
24
|
-
public func call(message: PushMessage) -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_bool____ {
|
|
25
|
-
let __result: Promise<Promise<Bool>> = self.closure(message)
|
|
26
|
-
return { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_bool____ in
|
|
27
|
-
let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____()
|
|
28
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____(__promise)
|
|
29
|
-
__result
|
|
30
|
-
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
31
|
-
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
32
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
33
|
-
__result
|
|
34
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
35
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
36
|
-
return __promise
|
|
37
|
-
}()) })
|
|
38
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
39
|
-
return __promise
|
|
40
|
-
}()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
45
|
-
* This acquires one additional strong reference on the object!
|
|
46
|
-
*/
|
|
47
|
-
@inline(__always)
|
|
48
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
49
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Casts an unsafe pointer to a `Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage`.
|
|
54
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage>`.
|
|
55
|
-
* This removes one strong reference from the object!
|
|
56
|
-
*/
|
|
57
|
-
@inline(__always)
|
|
58
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
59
|
-
return Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage>.fromOpaque(pointer).takeRetainedValue()
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_bool.swift
|
|
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
|
-
import NitroModules
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
12
|
-
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
-
*/
|
|
14
|
-
public final class Func_void_bool {
|
|
15
|
-
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
-
|
|
17
|
-
private let closure: (_ value: Bool) -> Void
|
|
18
|
-
|
|
19
|
-
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
20
|
-
self.closure = closure
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@inline(__always)
|
|
24
|
-
public func call(value: Bool) -> Void {
|
|
25
|
-
self.closure(value)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
-
* This acquires one additional strong reference on the object!
|
|
31
|
-
*/
|
|
32
|
-
@inline(__always)
|
|
33
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
39
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
40
|
-
* This removes one strong reference from the object!
|
|
41
|
-
*/
|
|
42
|
-
@inline(__always)
|
|
43
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
44
|
-
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_std__shared_ptr_Promise_bool__.swift
|
|
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
|
-
import NitroModules
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Wraps a Swift `(_ value: Promise<Bool>) -> Void` as a class.
|
|
12
|
-
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
-
*/
|
|
14
|
-
public final class Func_void_std__shared_ptr_Promise_bool__ {
|
|
15
|
-
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
-
|
|
17
|
-
private let closure: (_ value: Promise<Bool>) -> Void
|
|
18
|
-
|
|
19
|
-
public init(_ closure: @escaping (_ value: Promise<Bool>) -> Void) {
|
|
20
|
-
self.closure = closure
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@inline(__always)
|
|
24
|
-
public func call(value: bridge.std__shared_ptr_Promise_bool__) -> Void {
|
|
25
|
-
self.closure({ () -> Promise<Bool> in
|
|
26
|
-
let __promise = Promise<Bool>()
|
|
27
|
-
let __resolver = { (__result: Bool) in
|
|
28
|
-
__promise.resolve(withResult: __result)
|
|
29
|
-
}
|
|
30
|
-
let __rejecter = { (__error: Error) in
|
|
31
|
-
__promise.reject(withError: __error)
|
|
32
|
-
}
|
|
33
|
-
let __resolverCpp = { () -> bridge.Func_void_bool in
|
|
34
|
-
let __closureWrapper = Func_void_bool(__resolver)
|
|
35
|
-
return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
|
|
36
|
-
}()
|
|
37
|
-
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
38
|
-
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
39
|
-
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
40
|
-
}()
|
|
41
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(value)
|
|
42
|
-
__promiseHolder.addOnResolvedListenerCopy(__resolverCpp)
|
|
43
|
-
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
44
|
-
return __promise
|
|
45
|
-
}())
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
50
|
-
* This acquires one additional strong reference on the object!
|
|
51
|
-
*/
|
|
52
|
-
@inline(__always)
|
|
53
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
54
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Casts an unsafe pointer to a `Func_void_std__shared_ptr_Promise_bool__`.
|
|
59
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_Promise_bool__>`.
|
|
60
|
-
* This removes one strong reference from the object!
|
|
61
|
-
*/
|
|
62
|
-
@inline(__always)
|
|
63
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_Promise_bool__ {
|
|
64
|
-
return Unmanaged<Func_void_std__shared_ptr_Promise_bool__>.fromOpaque(pointer).takeRetainedValue()
|
|
65
|
-
}
|
|
66
|
-
}
|