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.
Files changed (91) hide show
  1. package/LICENSE +20 -0
  2. package/PushSignal.podspec +31 -0
  3. package/README.md +125 -0
  4. package/README.ru.md +125 -0
  5. package/android/CMakeLists.txt +24 -0
  6. package/android/build.gradle +115 -0
  7. package/android/src/main/AndroidManifest.xml +18 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  9. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +44 -0
  10. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +353 -0
  11. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalInitProvider.kt +34 -0
  12. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalMessagingService.kt +15 -0
  13. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalPackage.kt +22 -0
  14. package/ios/PushSignal.swift +38 -0
  15. package/ios/PushSignalCenter.swift +430 -0
  16. package/ios/PushSignalLaunchStore.h +21 -0
  17. package/ios/PushSignalLaunchStore.m +26 -0
  18. package/lib/module/PushSignal.nitro.js +4 -0
  19. package/lib/module/PushSignal.nitro.js.map +1 -0
  20. package/lib/module/index.js +4 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/pushSignal.js +19 -0
  24. package/lib/module/pushSignal.js.map +1 -0
  25. package/lib/module/pushSignal.native.js +46 -0
  26. package/lib/module/pushSignal.native.js.map +1 -0
  27. package/lib/typescript/package.json +1 -0
  28. package/lib/typescript/src/PushSignal.nitro.d.ts +33 -0
  29. package/lib/typescript/src/PushSignal.nitro.d.ts.map +1 -0
  30. package/lib/typescript/src/index.d.ts +3 -0
  31. package/lib/typescript/src/index.d.ts.map +1 -0
  32. package/lib/typescript/src/pushSignal.d.ts +8 -0
  33. package/lib/typescript/src/pushSignal.d.ts.map +1 -0
  34. package/lib/typescript/src/pushSignal.native.d.ts +8 -0
  35. package/lib/typescript/src/pushSignal.native.d.ts.map +1 -0
  36. package/nitro.json +23 -0
  37. package/nitrogen/generated/android/c++/JAndroidFirebaseConfig.hpp +70 -0
  38. package/nitrogen/generated/android/c++/JFunc_void_PushMessage.hpp +80 -0
  39. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +138 -0
  40. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +68 -0
  41. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
  42. package/nitrogen/generated/android/c++/JPushCredentials.hpp +70 -0
  43. package/nitrogen/generated/android/c++/JPushEnvironment.hpp +58 -0
  44. package/nitrogen/generated/android/c++/JPushMessage.hpp +84 -0
  45. package/nitrogen/generated/android/c++/JPushPlatform.hpp +58 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt +66 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_void_PushMessage.kt +78 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +87 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PermissionStatus.kt +24 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushCredentials.kt +61 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushEnvironment.kt +23 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushMessage.kt +66 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +23 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/pushsignalOnLoad.kt +35 -0
  55. package/nitrogen/generated/android/pushsignal+autolinking.cmake +81 -0
  56. package/nitrogen/generated/android/pushsignal+autolinking.gradle +27 -0
  57. package/nitrogen/generated/android/pushsignalOnLoad.cpp +56 -0
  58. package/nitrogen/generated/android/pushsignalOnLoad.hpp +34 -0
  59. package/nitrogen/generated/ios/PushSignal+autolinking.rb +62 -0
  60. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +65 -0
  61. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +257 -0
  62. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +66 -0
  63. package/nitrogen/generated/ios/PushSignalAutolinking.mm +33 -0
  64. package/nitrogen/generated/ios/PushSignalAutolinking.swift +26 -0
  65. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +137 -0
  67. package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +96 -0
  68. package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +46 -0
  69. package/nitrogen/generated/ios/swift/Func_void_PushCredentials.swift +46 -0
  70. package/nitrogen/generated/ios/swift/Func_void_PushMessage.swift +46 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  72. package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +60 -0
  73. package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +226 -0
  74. package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
  75. package/nitrogen/generated/ios/swift/PushCredentials.swift +45 -0
  76. package/nitrogen/generated/ios/swift/PushEnvironment.swift +40 -0
  77. package/nitrogen/generated/ios/swift/PushMessage.swift +97 -0
  78. package/nitrogen/generated/ios/swift/PushPlatform.swift +40 -0
  79. package/nitrogen/generated/shared/c++/AndroidFirebaseConfig.hpp +96 -0
  80. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp +26 -0
  81. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +79 -0
  82. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
  83. package/nitrogen/generated/shared/c++/PushCredentials.hpp +97 -0
  84. package/nitrogen/generated/shared/c++/PushEnvironment.hpp +76 -0
  85. package/nitrogen/generated/shared/c++/PushMessage.hpp +97 -0
  86. package/nitrogen/generated/shared/c++/PushPlatform.hpp +76 -0
  87. package/package.json +187 -0
  88. package/src/PushSignal.nitro.ts +37 -0
  89. package/src/index.tsx +16 -0
  90. package/src/pushSignal.native.tsx +67 -0
  91. package/src/pushSignal.tsx +32 -0
@@ -0,0 +1,79 @@
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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `AndroidFirebaseConfig` to properly resolve imports.
17
+ namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
18
+ // Forward declaration of `PermissionStatus` to properly resolve imports.
19
+ namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
20
+ // Forward declaration of `PushCredentials` to properly resolve imports.
21
+ namespace margelo::nitro::pushsignal { struct PushCredentials; }
22
+ // Forward declaration of `PushMessage` to properly resolve imports.
23
+ namespace margelo::nitro::pushsignal { struct PushMessage; }
24
+
25
+ #include "AndroidFirebaseConfig.hpp"
26
+ #include "PermissionStatus.hpp"
27
+ #include <NitroModules/Promise.hpp>
28
+ #include "PushCredentials.hpp"
29
+ #include "PushMessage.hpp"
30
+ #include <functional>
31
+
32
+ namespace margelo::nitro::pushsignal {
33
+
34
+ using namespace margelo::nitro;
35
+
36
+ /**
37
+ * An abstract base class for `PushSignal`
38
+ * Inherit this class to create instances of `HybridPushSignalSpec` in C++.
39
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
40
+ * @example
41
+ * ```cpp
42
+ * class HybridPushSignal: public HybridPushSignalSpec {
43
+ * public:
44
+ * HybridPushSignal(...): HybridObject(TAG) { ... }
45
+ * // ...
46
+ * };
47
+ * ```
48
+ */
49
+ class HybridPushSignalSpec: public virtual HybridObject {
50
+ public:
51
+ // Constructor
52
+ explicit HybridPushSignalSpec(): HybridObject(TAG) { }
53
+
54
+ // Destructor
55
+ ~HybridPushSignalSpec() override = default;
56
+
57
+ public:
58
+ // Properties
59
+
60
+
61
+ public:
62
+ // Methods
63
+ virtual void initialize(const AndroidFirebaseConfig& config) = 0;
64
+ virtual std::shared_ptr<Promise<PermissionStatus>> getPermissionStatus() = 0;
65
+ virtual std::shared_ptr<Promise<PermissionStatus>> requestPermission() = 0;
66
+ virtual std::shared_ptr<Promise<PushCredentials>> getCredentials() = 0;
67
+ virtual void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
68
+ virtual void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
69
+
70
+ protected:
71
+ // Hybrid Setup
72
+ void loadHybridMethods() override;
73
+
74
+ protected:
75
+ // Tag for logging
76
+ static constexpr auto TAG = "PushSignal";
77
+ };
78
+
79
+ } // namespace margelo::nitro::pushsignal
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// PermissionStatus.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::pushsignal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PermissionStatus).
30
+ */
31
+ enum class PermissionStatus {
32
+ AUTHORIZED SWIFT_NAME(authorized) = 0,
33
+ DENIED SWIFT_NAME(denied) = 1,
34
+ NOTDETERMINED SWIFT_NAME(notdetermined) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::pushsignal
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ PermissionStatus <> JS PermissionStatus (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::pushsignal::PermissionStatus> final {
44
+ static inline margelo::nitro::pushsignal::PermissionStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("authorized"): return margelo::nitro::pushsignal::PermissionStatus::AUTHORIZED;
48
+ case hashString("denied"): return margelo::nitro::pushsignal::PermissionStatus::DENIED;
49
+ case hashString("notDetermined"): return margelo::nitro::pushsignal::PermissionStatus::NOTDETERMINED;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PermissionStatus - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pushsignal::PermissionStatus arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::pushsignal::PermissionStatus::AUTHORIZED: return JSIConverter<std::string>::toJSI(runtime, "authorized");
57
+ case margelo::nitro::pushsignal::PermissionStatus::DENIED: return JSIConverter<std::string>::toJSI(runtime, "denied");
58
+ case margelo::nitro::pushsignal::PermissionStatus::NOTDETERMINED: return JSIConverter<std::string>::toJSI(runtime, "notDetermined");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert PermissionStatus to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("authorized"):
71
+ case hashString("denied"):
72
+ case hashString("notDetermined"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,97 @@
1
+ ///
2
+ /// PushCredentials.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `PushPlatform` to properly resolve imports.
32
+ namespace margelo::nitro::pushsignal { enum class PushPlatform; }
33
+ // Forward declaration of `PushEnvironment` to properly resolve imports.
34
+ namespace margelo::nitro::pushsignal { enum class PushEnvironment; }
35
+
36
+ #include "PushPlatform.hpp"
37
+ #include <string>
38
+ #include "PushEnvironment.hpp"
39
+ #include <optional>
40
+
41
+ namespace margelo::nitro::pushsignal {
42
+
43
+ /**
44
+ * A struct which can be represented as a JavaScript object (PushCredentials).
45
+ */
46
+ struct PushCredentials final {
47
+ public:
48
+ PushPlatform platform SWIFT_PRIVATE;
49
+ std::string token SWIFT_PRIVATE;
50
+ std::optional<PushEnvironment> environment SWIFT_PRIVATE;
51
+
52
+ public:
53
+ PushCredentials() = default;
54
+ explicit PushCredentials(PushPlatform platform, std::string token, std::optional<PushEnvironment> environment): platform(platform), token(token), environment(environment) {}
55
+
56
+ public:
57
+ friend bool operator==(const PushCredentials& lhs, const PushCredentials& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::pushsignal
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ PushCredentials <> JS PushCredentials (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::pushsignal::PushCredentials> final {
67
+ static inline margelo::nitro::pushsignal::PushCredentials fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::pushsignal::PushCredentials(
70
+ JSIConverter<margelo::nitro::pushsignal::PushPlatform>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "platform"))),
71
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "token"))),
72
+ JSIConverter<std::optional<margelo::nitro::pushsignal::PushEnvironment>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "environment")))
73
+ );
74
+ }
75
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pushsignal::PushCredentials& arg) {
76
+ jsi::Object obj(runtime);
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "platform"), JSIConverter<margelo::nitro::pushsignal::PushPlatform>::toJSI(runtime, arg.platform));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "token"), JSIConverter<std::string>::toJSI(runtime, arg.token));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "environment"), JSIConverter<std::optional<margelo::nitro::pushsignal::PushEnvironment>>::toJSI(runtime, arg.environment));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<margelo::nitro::pushsignal::PushPlatform>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "platform")))) return false;
91
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "token")))) return false;
92
+ if (!JSIConverter<std::optional<margelo::nitro::pushsignal::PushEnvironment>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "environment")))) return false;
93
+ return true;
94
+ }
95
+ };
96
+
97
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// PushEnvironment.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::pushsignal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PushEnvironment).
30
+ */
31
+ enum class PushEnvironment {
32
+ SANDBOX SWIFT_NAME(sandbox) = 0,
33
+ PRODUCTION SWIFT_NAME(production) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::pushsignal
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ PushEnvironment <> JS PushEnvironment (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::pushsignal::PushEnvironment> final {
43
+ static inline margelo::nitro::pushsignal::PushEnvironment fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("sandbox"): return margelo::nitro::pushsignal::PushEnvironment::SANDBOX;
47
+ case hashString("production"): return margelo::nitro::pushsignal::PushEnvironment::PRODUCTION;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PushEnvironment - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pushsignal::PushEnvironment arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::pushsignal::PushEnvironment::SANDBOX: return JSIConverter<std::string>::toJSI(runtime, "sandbox");
55
+ case margelo::nitro::pushsignal::PushEnvironment::PRODUCTION: return JSIConverter<std::string>::toJSI(runtime, "production");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert PushEnvironment to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("sandbox"):
68
+ case hashString("production"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,97 @@
1
+ ///
2
+ /// 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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+ #include <unordered_map>
36
+
37
+ namespace margelo::nitro::pushsignal {
38
+
39
+ /**
40
+ * A struct which can be represented as a JavaScript object (PushMessage).
41
+ */
42
+ struct PushMessage final {
43
+ public:
44
+ std::optional<std::string> id SWIFT_PRIVATE;
45
+ std::optional<std::string> title SWIFT_PRIVATE;
46
+ std::optional<std::string> body SWIFT_PRIVATE;
47
+ std::unordered_map<std::string, std::string> data SWIFT_PRIVATE;
48
+
49
+ public:
50
+ PushMessage() = default;
51
+ explicit PushMessage(std::optional<std::string> id, std::optional<std::string> title, std::optional<std::string> body, std::unordered_map<std::string, std::string> data): id(id), title(title), body(body), data(data) {}
52
+
53
+ public:
54
+ friend bool operator==(const PushMessage& lhs, const PushMessage& rhs) = default;
55
+ };
56
+
57
+ } // namespace margelo::nitro::pushsignal
58
+
59
+ namespace margelo::nitro {
60
+
61
+ // C++ PushMessage <> JS PushMessage (object)
62
+ template <>
63
+ struct JSIConverter<margelo::nitro::pushsignal::PushMessage> final {
64
+ static inline margelo::nitro::pushsignal::PushMessage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
65
+ jsi::Object obj = arg.asObject(runtime);
66
+ return margelo::nitro::pushsignal::PushMessage(
67
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
68
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
69
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body"))),
70
+ JSIConverter<std::unordered_map<std::string, std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))
71
+ );
72
+ }
73
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pushsignal::PushMessage& arg) {
74
+ jsi::Object obj(runtime);
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.id));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "body"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.body));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::unordered_map<std::string, std::string>>::toJSI(runtime, arg.data));
79
+ return obj;
80
+ }
81
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
82
+ if (!value.isObject()) {
83
+ return false;
84
+ }
85
+ jsi::Object obj = value.getObject(runtime);
86
+ if (!nitro::isPlainObject(runtime, obj)) {
87
+ return false;
88
+ }
89
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
90
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
91
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body")))) return false;
92
+ if (!JSIConverter<std::unordered_map<std::string, std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
93
+ return true;
94
+ }
95
+ };
96
+
97
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// PushPlatform.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::pushsignal {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (PushPlatform).
30
+ */
31
+ enum class PushPlatform {
32
+ IOS SWIFT_NAME(ios) = 0,
33
+ ANDROID SWIFT_NAME(android) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::pushsignal
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ PushPlatform <> JS PushPlatform (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::pushsignal::PushPlatform> final {
43
+ static inline margelo::nitro::pushsignal::PushPlatform fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("ios"): return margelo::nitro::pushsignal::PushPlatform::IOS;
47
+ case hashString("android"): return margelo::nitro::pushsignal::PushPlatform::ANDROID;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PushPlatform - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pushsignal::PushPlatform arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::pushsignal::PushPlatform::IOS: return JSIConverter<std::string>::toJSI(runtime, "ios");
55
+ case margelo::nitro::pushsignal::PushPlatform::ANDROID: return JSIConverter<std::string>::toJSI(runtime, "android");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert PushPlatform to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("ios"):
68
+ case hashString("android"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro