react-native-push-signal 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -18
- package/README.ru.md +24 -18
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +9 -15
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +33 -104
- package/ios/PushSignal.swift +2 -11
- package/ios/PushSignalCenter.swift +0 -35
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pushSignal.js +1 -7
- package/lib/module/pushSignal.js.map +1 -1
- package/lib/module/pushSignal.native.js +1 -7
- package/lib/module/pushSignal.native.js.map +1 -1
- package/lib/typescript/src/PushSignal.nitro.d.ts +7 -9
- package/lib/typescript/src/PushSignal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/pushSignal.d.ts +2 -4
- package/lib/typescript/src/pushSignal.d.ts.map +1 -1
- package/lib/typescript/src/pushSignal.native.d.ts +2 -4
- package/lib/typescript/src/pushSignal.native.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JAndroidFirebaseConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +7 -31
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +1 -3
- package/nitrogen/generated/android/c++/JPushPlatform.hpp +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt +14 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +1 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +1 -1
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +5 -5
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +49 -52
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +0 -3
- package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +2 -19
- package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +17 -17
- package/nitrogen/generated/ios/swift/{Func_void_PermissionStatus.swift → Func_void.swift} +11 -11
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +1 -3
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +8 -38
- package/nitrogen/generated/ios/swift/PushPlatform.swift +4 -4
- package/nitrogen/generated/shared/c++/AndroidFirebaseConfig.hpp +17 -17
- package/nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +2 -7
- package/nitrogen/generated/shared/c++/PushPlatform.hpp +4 -4
- package/package.json +2 -2
- package/src/PushSignal.nitro.ts +7 -9
- package/src/index.tsx +0 -3
- package/src/pushSignal.native.tsx +2 -11
- package/src/pushSignal.tsx +3 -10
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +0 -61
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PermissionStatus.kt +0 -24
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +0 -44
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +0 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushSignal.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"pushSignal.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,WAAW,EACZ,MAAM,uBAAoB,CAAC;AAE5B,wBAAsB,UAAU,CAC9B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAAG;AAEnB,wBAAsB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAE/D;AAED,wBAAgB,SAAS,CACvB,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACxC,MAAM,IAAI,CAEZ;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACxC,MAAM,IAAI,CAEZ"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { AndroidFirebaseConfig,
|
|
2
|
-
export declare function initialize(config?: AndroidFirebaseConfig): void
|
|
3
|
-
export declare function getPermissionStatus(): Promise<PermissionStatus>;
|
|
4
|
-
export declare function requestPermission(): Promise<PermissionStatus>;
|
|
1
|
+
import type { AndroidFirebaseConfig, PushCredentials, PushMessage } from './PushSignal.nitro.js';
|
|
2
|
+
export declare function initialize(config?: AndroidFirebaseConfig): Promise<void>;
|
|
5
3
|
export declare function getCredentials(): Promise<PushCredentials>;
|
|
6
4
|
export declare function onMessage(listener: (message: PushMessage) => void): () => void;
|
|
7
5
|
export declare function onNotificationPress(listener: (message: PushMessage) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushSignal.native.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"pushSignal.native.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,WAAW,EAEZ,MAAM,uBAAoB,CAAC;AAyB5B,wBAAgB,UAAU,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAEzD;AAED,wBAAgB,SAAS,CACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACvC,MAAM,IAAI,CAMZ;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACvC,MAAM,IAAI,CAMZ"}
|
|
@@ -32,19 +32,19 @@ namespace margelo::nitro::pushsignal {
|
|
|
32
32
|
[[nodiscard]]
|
|
33
33
|
AndroidFirebaseConfig toCpp() const {
|
|
34
34
|
static const auto clazz = javaClassStatic();
|
|
35
|
-
static const auto
|
|
36
|
-
jni::local_ref<jni::JString>
|
|
37
|
-
static const auto
|
|
38
|
-
jni::local_ref<jni::JString>
|
|
39
|
-
static const auto
|
|
40
|
-
jni::local_ref<jni::JString>
|
|
41
|
-
static const auto
|
|
42
|
-
jni::local_ref<jni::JString>
|
|
35
|
+
static const auto fieldProject_id = clazz->getField<jni::JString>("project_id");
|
|
36
|
+
jni::local_ref<jni::JString> project_id = this->getFieldValue(fieldProject_id);
|
|
37
|
+
static const auto fieldMobilesdk_app_id = clazz->getField<jni::JString>("mobilesdk_app_id");
|
|
38
|
+
jni::local_ref<jni::JString> mobilesdk_app_id = this->getFieldValue(fieldMobilesdk_app_id);
|
|
39
|
+
static const auto fieldCurrent_key = clazz->getField<jni::JString>("current_key");
|
|
40
|
+
jni::local_ref<jni::JString> current_key = this->getFieldValue(fieldCurrent_key);
|
|
41
|
+
static const auto fieldProject_number = clazz->getField<jni::JString>("project_number");
|
|
42
|
+
jni::local_ref<jni::JString> project_number = this->getFieldValue(fieldProject_number);
|
|
43
43
|
return AndroidFirebaseConfig(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
project_id != nullptr ? std::make_optional(project_id->toStdString()) : std::nullopt,
|
|
45
|
+
mobilesdk_app_id != nullptr ? std::make_optional(mobilesdk_app_id->toStdString()) : std::nullopt,
|
|
46
|
+
current_key != nullptr ? std::make_optional(current_key->toStdString()) : std::nullopt,
|
|
47
|
+
project_number != nullptr ? std::make_optional(project_number->toStdString()) : std::nullopt
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -59,10 +59,10 @@ namespace margelo::nitro::pushsignal {
|
|
|
59
59
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
60
60
|
return create(
|
|
61
61
|
clazz,
|
|
62
|
-
value.
|
|
63
|
-
value.
|
|
64
|
-
value.
|
|
65
|
-
value.
|
|
62
|
+
value.project_id.has_value() ? jni::make_jstring(value.project_id.value()) : nullptr,
|
|
63
|
+
value.mobilesdk_app_id.has_value() ? jni::make_jstring(value.mobilesdk_app_id.value()) : nullptr,
|
|
64
|
+
value.current_key.has_value() ? jni::make_jstring(value.current_key.value()) : nullptr,
|
|
65
|
+
value.project_number.has_value() ? jni::make_jstring(value.project_number.value()) : nullptr
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridPushSignalSpec.hpp"
|
|
9
9
|
|
|
10
|
-
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
11
|
-
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
12
10
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
13
11
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
14
12
|
// Forward declaration of `PushPlatform` to properly resolve imports.
|
|
@@ -20,10 +18,9 @@ namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
|
|
|
20
18
|
// Forward declaration of `PushMessage` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
22
20
|
|
|
23
|
-
#include "PermissionStatus.hpp"
|
|
24
21
|
#include <NitroModules/Promise.hpp>
|
|
25
22
|
#include <NitroModules/JPromise.hpp>
|
|
26
|
-
#include
|
|
23
|
+
#include <NitroModules/JUnit.hpp>
|
|
27
24
|
#include "PushCredentials.hpp"
|
|
28
25
|
#include "JPushCredentials.hpp"
|
|
29
26
|
#include "PushPlatform.hpp"
|
|
@@ -74,34 +71,13 @@ namespace margelo::nitro::pushsignal {
|
|
|
74
71
|
|
|
75
72
|
|
|
76
73
|
// Methods
|
|
77
|
-
void JHybridPushSignalSpec::initialize(const AndroidFirebaseConfig& config) {
|
|
78
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<
|
|
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);
|
|
74
|
+
std::shared_ptr<Promise<void>> JHybridPushSignalSpec::initialize(const AndroidFirebaseConfig& config) {
|
|
75
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JAndroidFirebaseConfig> /* config */)>("initialize");
|
|
76
|
+
auto __result = method(_javaPart, JAndroidFirebaseConfig::fromCpp(config));
|
|
100
77
|
return [&]() {
|
|
101
|
-
auto __promise = Promise<
|
|
102
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>&
|
|
103
|
-
|
|
104
|
-
__promise->resolve(__result->toCpp());
|
|
78
|
+
auto __promise = Promise<void>::create();
|
|
79
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
80
|
+
__promise->resolve();
|
|
105
81
|
});
|
|
106
82
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
107
83
|
jni::JniException __jniError(__throwable);
|
|
@@ -54,9 +54,7 @@ namespace margelo::nitro::pushsignal {
|
|
|
54
54
|
|
|
55
55
|
public:
|
|
56
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;
|
|
57
|
+
std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) override;
|
|
60
58
|
std::shared_ptr<Promise<PushCredentials>> getCredentials() override;
|
|
61
59
|
void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) override;
|
|
62
60
|
void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) override;
|
|
@@ -45,9 +45,9 @@ namespace margelo::nitro::pushsignal {
|
|
|
45
45
|
case PushPlatform::IOS:
|
|
46
46
|
static const auto fieldIOS = clazz->getStaticField<JPushPlatform>("IOS");
|
|
47
47
|
return clazz->getStaticFieldValue(fieldIOS);
|
|
48
|
-
case PushPlatform::
|
|
49
|
-
static const auto
|
|
50
|
-
return clazz->getStaticFieldValue(
|
|
48
|
+
case PushPlatform::ANDROID_OS:
|
|
49
|
+
static const auto fieldANDROID_OS = clazz->getStaticField<JPushPlatform>("ANDROID_OS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldANDROID_OS);
|
|
51
51
|
default:
|
|
52
52
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
53
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt
CHANGED
|
@@ -20,34 +20,34 @@ import java.util.Objects
|
|
|
20
20
|
data class AndroidFirebaseConfig(
|
|
21
21
|
@DoNotStrip
|
|
22
22
|
@Keep
|
|
23
|
-
val
|
|
23
|
+
val project_id: String?,
|
|
24
24
|
@DoNotStrip
|
|
25
25
|
@Keep
|
|
26
|
-
val
|
|
26
|
+
val mobilesdk_app_id: String?,
|
|
27
27
|
@DoNotStrip
|
|
28
28
|
@Keep
|
|
29
|
-
val
|
|
29
|
+
val current_key: String?,
|
|
30
30
|
@DoNotStrip
|
|
31
31
|
@Keep
|
|
32
|
-
val
|
|
32
|
+
val project_number: String?
|
|
33
33
|
) {
|
|
34
34
|
/* primary constructor */
|
|
35
35
|
|
|
36
36
|
override fun equals(other: Any?): Boolean {
|
|
37
37
|
if (this === other) return true
|
|
38
38
|
if (other !is AndroidFirebaseConfig) return false
|
|
39
|
-
return Objects.deepEquals(this.
|
|
40
|
-
&& Objects.deepEquals(this.
|
|
41
|
-
&& Objects.deepEquals(this.
|
|
42
|
-
&& Objects.deepEquals(this.
|
|
39
|
+
return Objects.deepEquals(this.project_id, other.project_id)
|
|
40
|
+
&& Objects.deepEquals(this.mobilesdk_app_id, other.mobilesdk_app_id)
|
|
41
|
+
&& Objects.deepEquals(this.current_key, other.current_key)
|
|
42
|
+
&& Objects.deepEquals(this.project_number, other.project_number)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
override fun hashCode(): Int {
|
|
46
46
|
return arrayOf<Any?>(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
project_id,
|
|
48
|
+
mobilesdk_app_id,
|
|
49
|
+
current_key,
|
|
50
|
+
project_number
|
|
51
51
|
).contentDeepHashCode()
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -59,8 +59,8 @@ data class AndroidFirebaseConfig(
|
|
|
59
59
|
@Keep
|
|
60
60
|
@Suppress("unused")
|
|
61
61
|
@JvmStatic
|
|
62
|
-
private fun fromCpp(
|
|
63
|
-
return AndroidFirebaseConfig(
|
|
62
|
+
private fun fromCpp(project_id: String?, mobilesdk_app_id: String?, current_key: String?, project_number: String?): AndroidFirebaseConfig {
|
|
63
|
+
return AndroidFirebaseConfig(project_id, mobilesdk_app_id, current_key, project_number)
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt
CHANGED
|
@@ -32,15 +32,7 @@ abstract class HybridPushSignalSpec: HybridObject() {
|
|
|
32
32
|
// Methods
|
|
33
33
|
@DoNotStrip
|
|
34
34
|
@Keep
|
|
35
|
-
abstract fun initialize(config: AndroidFirebaseConfig): Unit
|
|
36
|
-
|
|
37
|
-
@DoNotStrip
|
|
38
|
-
@Keep
|
|
39
|
-
abstract fun getPermissionStatus(): Promise<PermissionStatus>
|
|
40
|
-
|
|
41
|
-
@DoNotStrip
|
|
42
|
-
@Keep
|
|
43
|
-
abstract fun requestPermission(): Promise<PermissionStatus>
|
|
35
|
+
abstract fun initialize(config: AndroidFirebaseConfig): Promise<Unit>
|
|
44
36
|
|
|
45
37
|
@DoNotStrip
|
|
46
38
|
@Keep
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
namespace margelo::nitro::pushsignal::bridge::swift {
|
|
16
16
|
|
|
17
|
-
// pragma MARK: std::function<void(
|
|
18
|
-
|
|
19
|
-
auto swiftClosure = PushSignal::
|
|
20
|
-
return [swiftClosure = std::move(swiftClosure)](
|
|
21
|
-
swiftClosure.call(
|
|
17
|
+
// pragma MARK: std::function<void()>
|
|
18
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = PushSignal::Func_void::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
|
|
21
|
+
swiftClosure.call();
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
11
|
// Forward declaration of `HybridPushSignalSpec` to properly resolve imports.
|
|
12
12
|
namespace margelo::nitro::pushsignal { class HybridPushSignalSpec; }
|
|
13
|
-
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
14
|
-
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
15
13
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
16
14
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
17
15
|
// Forward declaration of `PushEnvironment` to properly resolve imports.
|
|
@@ -27,7 +25,6 @@ namespace PushSignal { class HybridPushSignalSpec_cxx; }
|
|
|
27
25
|
|
|
28
26
|
// Include C++ defined types
|
|
29
27
|
#include "HybridPushSignalSpec.hpp"
|
|
30
|
-
#include "PermissionStatus.hpp"
|
|
31
28
|
#include "PushCredentials.hpp"
|
|
32
29
|
#include "PushEnvironment.hpp"
|
|
33
30
|
#include "PushMessage.hpp"
|
|
@@ -48,53 +45,38 @@ namespace PushSignal { class HybridPushSignalSpec_cxx; }
|
|
|
48
45
|
*/
|
|
49
46
|
namespace margelo::nitro::pushsignal::bridge::swift {
|
|
50
47
|
|
|
51
|
-
// pragma MARK: std::
|
|
52
|
-
/**
|
|
53
|
-
* Specialized version of `std::optional<std::string>`.
|
|
54
|
-
*/
|
|
55
|
-
using std__optional_std__string_ = std::optional<std::string>;
|
|
56
|
-
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
57
|
-
return std::optional<std::string>(value);
|
|
58
|
-
}
|
|
59
|
-
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
60
|
-
return optional.has_value();
|
|
61
|
-
}
|
|
62
|
-
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
63
|
-
return optional.value();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// pragma MARK: std::shared_ptr<Promise<PermissionStatus>>
|
|
48
|
+
// pragma MARK: std::shared_ptr<Promise<void>>
|
|
67
49
|
/**
|
|
68
|
-
* Specialized version of `std::shared_ptr<Promise<
|
|
50
|
+
* Specialized version of `std::shared_ptr<Promise<void>>`.
|
|
69
51
|
*/
|
|
70
|
-
using
|
|
71
|
-
inline std::shared_ptr<Promise<
|
|
72
|
-
return Promise<
|
|
52
|
+
using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
|
|
53
|
+
inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
|
|
54
|
+
return Promise<void>::create();
|
|
73
55
|
}
|
|
74
|
-
inline PromiseHolder<
|
|
75
|
-
return PromiseHolder<
|
|
56
|
+
inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
|
|
57
|
+
return PromiseHolder<void>(std::move(promise));
|
|
76
58
|
}
|
|
77
59
|
|
|
78
|
-
// pragma MARK: std::function<void(
|
|
60
|
+
// pragma MARK: std::function<void()>
|
|
79
61
|
/**
|
|
80
|
-
* Specialized version of `std::function<void(
|
|
62
|
+
* Specialized version of `std::function<void()>`.
|
|
81
63
|
*/
|
|
82
|
-
using
|
|
64
|
+
using Func_void = std::function<void()>;
|
|
83
65
|
/**
|
|
84
|
-
* Wrapper class for a `std::function<void(
|
|
66
|
+
* Wrapper class for a `std::function<void()>`, this can be used from Swift.
|
|
85
67
|
*/
|
|
86
|
-
class
|
|
68
|
+
class Func_void_Wrapper final {
|
|
87
69
|
public:
|
|
88
|
-
explicit
|
|
89
|
-
inline void call(
|
|
90
|
-
_function->operator()(
|
|
70
|
+
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
|
|
71
|
+
inline void call() const noexcept {
|
|
72
|
+
_function->operator()();
|
|
91
73
|
}
|
|
92
74
|
private:
|
|
93
|
-
std::unique_ptr<std::function<void(
|
|
75
|
+
std::unique_ptr<std::function<void()>> _function;
|
|
94
76
|
} SWIFT_NONCOPYABLE;
|
|
95
|
-
|
|
96
|
-
inline
|
|
97
|
-
return
|
|
77
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
78
|
+
inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
|
|
79
|
+
return Func_void_Wrapper(std::move(value));
|
|
98
80
|
}
|
|
99
81
|
|
|
100
82
|
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
@@ -119,6 +101,21 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
119
101
|
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
120
102
|
}
|
|
121
103
|
|
|
104
|
+
// pragma MARK: std::optional<std::string>
|
|
105
|
+
/**
|
|
106
|
+
* Specialized version of `std::optional<std::string>`.
|
|
107
|
+
*/
|
|
108
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
109
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
110
|
+
return std::optional<std::string>(value);
|
|
111
|
+
}
|
|
112
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
113
|
+
return optional.has_value();
|
|
114
|
+
}
|
|
115
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
116
|
+
return optional.value();
|
|
117
|
+
}
|
|
118
|
+
|
|
122
119
|
// pragma MARK: std::optional<PushEnvironment>
|
|
123
120
|
/**
|
|
124
121
|
* Specialized version of `std::optional<PushEnvironment>`.
|
|
@@ -227,22 +224,13 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
227
224
|
using std__weak_ptr_HybridPushSignalSpec_ = std::weak_ptr<HybridPushSignalSpec>;
|
|
228
225
|
inline std__weak_ptr_HybridPushSignalSpec_ weakify_std__shared_ptr_HybridPushSignalSpec_(const std::shared_ptr<HybridPushSignalSpec>& strong) noexcept { return strong; }
|
|
229
226
|
|
|
230
|
-
// pragma MARK: Result<void
|
|
231
|
-
using
|
|
232
|
-
inline
|
|
233
|
-
return Result<void
|
|
234
|
-
}
|
|
235
|
-
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
|
|
236
|
-
return Result<void>::withError(error);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// pragma MARK: Result<std::shared_ptr<Promise<PermissionStatus>>>
|
|
240
|
-
using Result_std__shared_ptr_Promise_PermissionStatus___ = Result<std::shared_ptr<Promise<PermissionStatus>>>;
|
|
241
|
-
inline Result_std__shared_ptr_Promise_PermissionStatus___ create_Result_std__shared_ptr_Promise_PermissionStatus___(const std::shared_ptr<Promise<PermissionStatus>>& value) noexcept {
|
|
242
|
-
return Result<std::shared_ptr<Promise<PermissionStatus>>>::withValue(value);
|
|
227
|
+
// pragma MARK: Result<std::shared_ptr<Promise<void>>>
|
|
228
|
+
using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
|
|
229
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
|
|
230
|
+
return Result<std::shared_ptr<Promise<void>>>::withValue(value);
|
|
243
231
|
}
|
|
244
|
-
inline
|
|
245
|
-
return Result<std::shared_ptr<Promise<
|
|
232
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
|
|
233
|
+
return Result<std::shared_ptr<Promise<void>>>::withError(error);
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
// pragma MARK: Result<std::shared_ptr<Promise<PushCredentials>>>
|
|
@@ -253,5 +241,14 @@ namespace margelo::nitro::pushsignal::bridge::swift {
|
|
|
253
241
|
inline Result_std__shared_ptr_Promise_PushCredentials___ create_Result_std__shared_ptr_Promise_PushCredentials___(const std::exception_ptr& error) noexcept {
|
|
254
242
|
return Result<std::shared_ptr<Promise<PushCredentials>>>::withError(error);
|
|
255
243
|
}
|
|
244
|
+
|
|
245
|
+
// pragma MARK: Result<void>
|
|
246
|
+
using Result_void_ = Result<void>;
|
|
247
|
+
inline Result_void_ create_Result_void_() noexcept {
|
|
248
|
+
return Result<void>::withValue();
|
|
249
|
+
}
|
|
250
|
+
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
|
|
251
|
+
return Result<void>::withError(error);
|
|
252
|
+
}
|
|
256
253
|
|
|
257
254
|
} // namespace margelo::nitro::pushsignal::bridge::swift
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
|
|
13
13
|
// Forward declaration of `HybridPushSignalSpec` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::pushsignal { class HybridPushSignalSpec; }
|
|
15
|
-
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
16
|
-
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
17
15
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
18
16
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
19
17
|
// Forward declaration of `PushEnvironment` to properly resolve imports.
|
|
@@ -26,7 +24,6 @@ namespace margelo::nitro::pushsignal { enum class PushPlatform; }
|
|
|
26
24
|
// Include C++ defined types
|
|
27
25
|
#include "AndroidFirebaseConfig.hpp"
|
|
28
26
|
#include "HybridPushSignalSpec.hpp"
|
|
29
|
-
#include "PermissionStatus.hpp"
|
|
30
27
|
#include "PushCredentials.hpp"
|
|
31
28
|
#include "PushEnvironment.hpp"
|
|
32
29
|
#include "PushMessage.hpp"
|
|
@@ -14,8 +14,6 @@ namespace PushSignal { class HybridPushSignalSpec_cxx; }
|
|
|
14
14
|
|
|
15
15
|
// Forward declaration of `AndroidFirebaseConfig` to properly resolve imports.
|
|
16
16
|
namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
|
|
17
|
-
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
18
|
-
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
19
17
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
20
18
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
21
19
|
// Forward declaration of `PushPlatform` to properly resolve imports.
|
|
@@ -25,11 +23,10 @@ namespace margelo::nitro::pushsignal { enum class PushEnvironment; }
|
|
|
25
23
|
// Forward declaration of `PushMessage` to properly resolve imports.
|
|
26
24
|
namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
27
25
|
|
|
26
|
+
#include <NitroModules/Promise.hpp>
|
|
28
27
|
#include "AndroidFirebaseConfig.hpp"
|
|
29
28
|
#include <string>
|
|
30
29
|
#include <optional>
|
|
31
|
-
#include "PermissionStatus.hpp"
|
|
32
|
-
#include <NitroModules/Promise.hpp>
|
|
33
30
|
#include "PushCredentials.hpp"
|
|
34
31
|
#include "PushPlatform.hpp"
|
|
35
32
|
#include "PushEnvironment.hpp"
|
|
@@ -87,25 +84,11 @@ namespace margelo::nitro::pushsignal {
|
|
|
87
84
|
|
|
88
85
|
public:
|
|
89
86
|
// Methods
|
|
90
|
-
inline void initialize(const AndroidFirebaseConfig& config) override {
|
|
87
|
+
inline std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) override {
|
|
91
88
|
auto __result = _swiftPart.initialize(std::forward<decltype(config)>(config));
|
|
92
89
|
if (__result.hasError()) [[unlikely]] {
|
|
93
90
|
std::rethrow_exception(__result.error());
|
|
94
91
|
}
|
|
95
|
-
}
|
|
96
|
-
inline std::shared_ptr<Promise<PermissionStatus>> getPermissionStatus() override {
|
|
97
|
-
auto __result = _swiftPart.getPermissionStatus();
|
|
98
|
-
if (__result.hasError()) [[unlikely]] {
|
|
99
|
-
std::rethrow_exception(__result.error());
|
|
100
|
-
}
|
|
101
|
-
auto __value = std::move(__result.value());
|
|
102
|
-
return __value;
|
|
103
|
-
}
|
|
104
|
-
inline std::shared_ptr<Promise<PermissionStatus>> requestPermission() override {
|
|
105
|
-
auto __result = _swiftPart.requestPermission();
|
|
106
|
-
if (__result.hasError()) [[unlikely]] {
|
|
107
|
-
std::rethrow_exception(__result.error());
|
|
108
|
-
}
|
|
109
92
|
auto __value = std::move(__result.value());
|
|
110
93
|
return __value;
|
|
111
94
|
}
|
|
@@ -18,27 +18,27 @@ public extension AndroidFirebaseConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `AndroidFirebaseConfig`.
|
|
20
20
|
*/
|
|
21
|
-
init(
|
|
21
|
+
init(project_id: String?, mobilesdk_app_id: String?, current_key: String?, project_number: String?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
-
if let __unwrappedValue =
|
|
23
|
+
if let __unwrappedValue = project_id {
|
|
24
24
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
25
|
} else {
|
|
26
26
|
return .init()
|
|
27
27
|
}
|
|
28
28
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
29
|
-
if let __unwrappedValue =
|
|
29
|
+
if let __unwrappedValue = mobilesdk_app_id {
|
|
30
30
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
31
31
|
} else {
|
|
32
32
|
return .init()
|
|
33
33
|
}
|
|
34
34
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
35
|
-
if let __unwrappedValue =
|
|
35
|
+
if let __unwrappedValue = current_key {
|
|
36
36
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
37
37
|
} else {
|
|
38
38
|
return .init()
|
|
39
39
|
}
|
|
40
40
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
41
|
-
if let __unwrappedValue =
|
|
41
|
+
if let __unwrappedValue = project_number {
|
|
42
42
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
43
43
|
} else {
|
|
44
44
|
return .init()
|
|
@@ -47,10 +47,10 @@ public extension AndroidFirebaseConfig {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@inline(__always)
|
|
50
|
-
var
|
|
50
|
+
var project_id: String? {
|
|
51
51
|
return { () -> String? in
|
|
52
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
53
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
52
|
+
if bridge.has_value_std__optional_std__string_(self.__project_id) {
|
|
53
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__project_id)
|
|
54
54
|
return String(__unwrapped)
|
|
55
55
|
} else {
|
|
56
56
|
return nil
|
|
@@ -59,10 +59,10 @@ public extension AndroidFirebaseConfig {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
@inline(__always)
|
|
62
|
-
var
|
|
62
|
+
var mobilesdk_app_id: String? {
|
|
63
63
|
return { () -> String? in
|
|
64
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
65
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
64
|
+
if bridge.has_value_std__optional_std__string_(self.__mobilesdk_app_id) {
|
|
65
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__mobilesdk_app_id)
|
|
66
66
|
return String(__unwrapped)
|
|
67
67
|
} else {
|
|
68
68
|
return nil
|
|
@@ -71,10 +71,10 @@ public extension AndroidFirebaseConfig {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
@inline(__always)
|
|
74
|
-
var
|
|
74
|
+
var current_key: String? {
|
|
75
75
|
return { () -> String? in
|
|
76
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
77
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
76
|
+
if bridge.has_value_std__optional_std__string_(self.__current_key) {
|
|
77
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__current_key)
|
|
78
78
|
return String(__unwrapped)
|
|
79
79
|
} else {
|
|
80
80
|
return nil
|
|
@@ -83,10 +83,10 @@ public extension AndroidFirebaseConfig {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
@inline(__always)
|
|
86
|
-
var
|
|
86
|
+
var project_number: String? {
|
|
87
87
|
return { () -> String? in
|
|
88
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
89
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
88
|
+
if bridge.has_value_std__optional_std__string_(self.__project_number) {
|
|
89
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__project_number)
|
|
90
90
|
return String(__unwrapped)
|
|
91
91
|
} else {
|
|
92
92
|
return nil
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// Func_void.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
import NitroModules
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Wraps a Swift `(
|
|
11
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
12
12
|
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
13
|
*/
|
|
14
|
-
public final class
|
|
14
|
+
public final class Func_void {
|
|
15
15
|
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
16
|
|
|
17
|
-
private let closure: (
|
|
17
|
+
private let closure: () -> Void
|
|
18
18
|
|
|
19
|
-
public init(_ closure: @escaping (
|
|
19
|
+
public init(_ closure: @escaping () -> Void) {
|
|
20
20
|
self.closure = closure
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
@inline(__always)
|
|
24
|
-
public func call(
|
|
25
|
-
self.closure(
|
|
24
|
+
public func call() -> Void {
|
|
25
|
+
self.closure()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -35,12 +35,12 @@ public final class Func_void_PermissionStatus {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Casts an unsafe pointer to a `
|
|
39
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
40
40
|
* This removes one strong reference from the object!
|
|
41
41
|
*/
|
|
42
42
|
@inline(__always)
|
|
43
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) ->
|
|
44
|
-
return Unmanaged<
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
44
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -13,9 +13,7 @@ public protocol HybridPushSignalSpec_protocol: HybridObject {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Methods
|
|
16
|
-
func initialize(config: AndroidFirebaseConfig) throws -> Void
|
|
17
|
-
func getPermissionStatus() throws -> Promise<PermissionStatus>
|
|
18
|
-
func requestPermission() throws -> Promise<PermissionStatus>
|
|
16
|
+
func initialize(config: AndroidFirebaseConfig) throws -> Promise<Void>
|
|
19
17
|
func getCredentials() throws -> Promise<PushCredentials>
|
|
20
18
|
func setOnMessage(callback: @escaping (_ message: PushMessage) -> Void) throws -> Void
|
|
21
19
|
func setOnNotificationPress(callback: @escaping (_ message: PushMessage) -> Void) throws -> Void
|