react-native-push-signal 0.1.4 → 0.1.7

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 (103) hide show
  1. package/LICENSE +1 -1
  2. package/PushSignal.podspec +2 -12
  3. package/README.md +3 -11
  4. package/README.ru.md +3 -11
  5. package/android/build.gradle +1 -62
  6. package/android/consumer-rules.pro +3 -3
  7. package/android/src/main/AndroidManifest.xml +2 -2
  8. package/android/src/main/java/com/pushsignal/PushModels.kt +15 -0
  9. package/android/src/main/java/com/{margelo/nitro/pushsignal → pushsignal}/PushSignalCenter.kt +24 -71
  10. package/android/src/main/java/com/{margelo/nitro/pushsignal → pushsignal}/PushSignalInitProvider.kt +1 -1
  11. package/android/src/main/java/com/{margelo/nitro/pushsignal → pushsignal}/PushSignalMessagingService.kt +1 -1
  12. package/android/src/main/java/com/pushsignal/PushSignalModule.kt +88 -0
  13. package/android/src/main/java/com/pushsignal/PushSignalPackage.kt +30 -0
  14. package/ios/PushSignal.h +4 -0
  15. package/ios/PushSignal.mm +57 -0
  16. package/ios/PushSignalCenter.h +26 -0
  17. package/ios/PushSignalCenter.m +608 -0
  18. package/ios/PushSignalLaunchStore.m +6 -9
  19. package/lib/module/NativePushSignal.js +5 -0
  20. package/lib/module/NativePushSignal.js.map +1 -0
  21. package/lib/module/pushSignal.native.js +36 -12
  22. package/lib/module/pushSignal.native.js.map +1 -1
  23. package/lib/module/types.js +2 -0
  24. package/lib/module/types.js.map +1 -0
  25. package/lib/typescript/src/NativePushSignal.d.ts +22 -0
  26. package/lib/typescript/src/NativePushSignal.d.ts.map +1 -0
  27. package/lib/typescript/src/index.d.ts +1 -1
  28. package/lib/typescript/src/index.d.ts.map +1 -1
  29. package/lib/typescript/src/pushSignal.d.ts +1 -1
  30. package/lib/typescript/src/pushSignal.d.ts.map +1 -1
  31. package/lib/typescript/src/pushSignal.native.d.ts +1 -1
  32. package/lib/typescript/src/pushSignal.native.d.ts.map +1 -1
  33. package/lib/typescript/src/types.d.ts +22 -0
  34. package/lib/typescript/src/types.d.ts.map +1 -0
  35. package/package.json +14 -19
  36. package/src/NativePushSignal.ts +25 -0
  37. package/src/index.tsx +1 -1
  38. package/src/pushSignal.native.tsx +60 -22
  39. package/src/pushSignal.tsx +1 -1
  40. package/src/types.ts +25 -0
  41. package/android/CMakeLists.txt +0 -24
  42. package/android/src/main/cpp/cpp-adapter.cpp +0 -11
  43. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +0 -38
  44. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalPackage.kt +0 -22
  45. package/ios/PushSignal.swift +0 -29
  46. package/ios/PushSignalCenter.swift +0 -588
  47. package/lib/module/PushSignal.nitro.js +0 -4
  48. package/lib/module/PushSignal.nitro.js.map +0 -1
  49. package/lib/typescript/src/PushSignal.nitro.d.ts +0 -32
  50. package/lib/typescript/src/PushSignal.nitro.d.ts.map +0 -1
  51. package/nitro.json +0 -23
  52. package/nitrogen/generated/android/c++/JAndroidFirebaseConfig.hpp +0 -70
  53. package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.hpp +0 -128
  54. package/nitrogen/generated/android/c++/JFunc_void_PushMessage.hpp +0 -80
  55. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +0 -115
  56. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +0 -66
  57. package/nitrogen/generated/android/c++/JPushCredentials.hpp +0 -70
  58. package/nitrogen/generated/android/c++/JPushEnvironment.hpp +0 -58
  59. package/nitrogen/generated/android/c++/JPushMessage.hpp +0 -84
  60. package/nitrogen/generated/android/c++/JPushPlatform.hpp +0 -58
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt +0 -66
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.kt +0 -78
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_void_PushMessage.kt +0 -78
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +0 -79
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushCredentials.kt +0 -61
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushEnvironment.kt +0 -23
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushMessage.kt +0 -66
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +0 -23
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/pushsignalOnLoad.kt +0 -35
  70. package/nitrogen/generated/android/pushsignal+autolinking.cmake +0 -81
  71. package/nitrogen/generated/android/pushsignal+autolinking.gradle +0 -27
  72. package/nitrogen/generated/android/pushsignalOnLoad.cpp +0 -58
  73. package/nitrogen/generated/android/pushsignalOnLoad.hpp +0 -34
  74. package/nitrogen/generated/ios/PushSignal+autolinking.rb +0 -62
  75. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +0 -90
  76. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +0 -345
  77. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +0 -63
  78. package/nitrogen/generated/ios/PushSignalAutolinking.mm +0 -33
  79. package/nitrogen/generated/ios/PushSignalAutolinking.swift +0 -26
  80. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.cpp +0 -11
  81. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +0 -120
  82. package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +0 -96
  83. package/nitrogen/generated/ios/swift/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.swift +0 -61
  84. package/nitrogen/generated/ios/swift/Func_void.swift +0 -46
  85. package/nitrogen/generated/ios/swift/Func_void_PushCredentials.swift +0 -46
  86. package/nitrogen/generated/ios/swift/Func_void_PushMessage.swift +0 -46
  87. package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -46
  88. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -46
  89. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_Promise_bool__.swift +0 -66
  90. package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +0 -58
  91. package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +0 -217
  92. package/nitrogen/generated/ios/swift/PushCredentials.swift +0 -45
  93. package/nitrogen/generated/ios/swift/PushEnvironment.swift +0 -40
  94. package/nitrogen/generated/ios/swift/PushMessage.swift +0 -97
  95. package/nitrogen/generated/ios/swift/PushPlatform.swift +0 -40
  96. package/nitrogen/generated/shared/c++/AndroidFirebaseConfig.hpp +0 -96
  97. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp +0 -24
  98. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +0 -74
  99. package/nitrogen/generated/shared/c++/PushCredentials.hpp +0 -97
  100. package/nitrogen/generated/shared/c++/PushEnvironment.hpp +0 -76
  101. package/nitrogen/generated/shared/c++/PushMessage.hpp +0 -97
  102. package/nitrogen/generated/shared/c++/PushPlatform.hpp +0 -76
  103. package/src/PushSignal.nitro.ts +0 -39
@@ -1,74 +0,0 @@
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 `PushCredentials` to properly resolve imports.
19
- namespace margelo::nitro::pushsignal { struct PushCredentials; }
20
- // Forward declaration of `PushMessage` to properly resolve imports.
21
- namespace margelo::nitro::pushsignal { struct PushMessage; }
22
-
23
- #include <NitroModules/Promise.hpp>
24
- #include "AndroidFirebaseConfig.hpp"
25
- #include "PushCredentials.hpp"
26
- #include "PushMessage.hpp"
27
- #include <functional>
28
-
29
- namespace margelo::nitro::pushsignal {
30
-
31
- using namespace margelo::nitro;
32
-
33
- /**
34
- * An abstract base class for `PushSignal`
35
- * Inherit this class to create instances of `HybridPushSignalSpec` in C++.
36
- * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
37
- * @example
38
- * ```cpp
39
- * class HybridPushSignal: public HybridPushSignalSpec {
40
- * public:
41
- * HybridPushSignal(...): HybridObject(TAG) { ... }
42
- * // ...
43
- * };
44
- * ```
45
- */
46
- class HybridPushSignalSpec: public virtual HybridObject {
47
- public:
48
- // Constructor
49
- explicit HybridPushSignalSpec(): HybridObject(TAG) { }
50
-
51
- // Destructor
52
- ~HybridPushSignalSpec() override = default;
53
-
54
- public:
55
- // Properties
56
-
57
-
58
- public:
59
- // Methods
60
- virtual std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) = 0;
61
- virtual std::shared_ptr<Promise<PushCredentials>> getCredentials() = 0;
62
- virtual void setOnMessage(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& callback) = 0;
63
- virtual void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
64
-
65
- protected:
66
- // Hybrid Setup
67
- void loadHybridMethods() override;
68
-
69
- protected:
70
- // Tag for logging
71
- static constexpr auto TAG = "PushSignal";
72
- };
73
-
74
- } // namespace margelo::nitro::pushsignal
@@ -1,97 +0,0 @@
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
@@ -1,76 +0,0 @@
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
@@ -1,97 +0,0 @@
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
@@ -1,76 +0,0 @@
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_OS SWIFT_NAME(androidOs) = 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_os"): return margelo::nitro::pushsignal::PushPlatform::ANDROID_OS;
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_OS: return JSIConverter<std::string>::toJSI(runtime, "android_os");
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_os"):
69
- return true;
70
- default:
71
- return false;
72
- }
73
- }
74
- };
75
-
76
- } // namespace margelo::nitro
@@ -1,39 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
-
3
- /** JS/C++ name cannot be `android`: NDK defines `-DANDROID` and breaks the generated enum. */
4
- export type PushPlatform = 'ios' | 'android_os';
5
- export type PushEnvironment = 'sandbox' | 'production';
6
-
7
- export interface PushCredentials {
8
- platform: PushPlatform;
9
- token: string;
10
- environment?: PushEnvironment;
11
- }
12
-
13
- export interface PushMessage {
14
- id?: string;
15
- title?: string;
16
- body?: string;
17
- data: Record<string, string>;
18
- }
19
-
20
- export type OnMessageListener = (
21
- message: PushMessage
22
- ) => boolean | void | Promise<boolean | void>;
23
-
24
- export interface AndroidFirebaseConfig {
25
- project_id?: string;
26
- mobilesdk_app_id?: string;
27
- current_key?: string;
28
- project_number?: string;
29
- }
30
-
31
- export interface PushSignal extends HybridObject<{
32
- ios: 'swift';
33
- android: 'kotlin';
34
- }> {
35
- initialize(config: AndroidFirebaseConfig): Promise<void>;
36
- getCredentials(): Promise<PushCredentials>;
37
- setOnMessage(callback: (message: PushMessage) => Promise<boolean>): void;
38
- setOnNotificationPress(callback: (message: PushMessage) => void): void;
39
- }