react-native-nitro-ali-push 0.0.0-stage → 1.0.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +215 -2
  3. package/android/CMakeLists.txt +31 -0
  4. package/android/build.gradle +139 -0
  5. package/android/src/main/AndroidManifest.xml +30 -0
  6. package/android/src/main/java/com/margelo/nitro/alipush/AliPushMessageReceiver.kt +156 -0
  7. package/android/src/main/java/com/margelo/nitro/alipush/HybridAliPushPlugin.kt +303 -0
  8. package/android/src/main/java/com/margelo/nitro/alipush/ThirdPartMessageActivity.kt +26 -0
  9. package/ios/HybridAliPushPlugin.swift +516 -0
  10. package/lib/index.d.ts +195 -0
  11. package/lib/index.js +269 -0
  12. package/lib/specs/AliPushPlugin.nitro.d.ts +88 -0
  13. package/lib/specs/AliPushPlugin.nitro.js +2 -0
  14. package/lib/types.d.ts +111 -0
  15. package/lib/types.js +11 -0
  16. package/nitrogen/generated/.gitattributes +1 -0
  17. package/nitrogen/generated/android/NitroAliPush+autolinking.cmake +84 -0
  18. package/nitrogen/generated/android/NitroAliPush+autolinking.gradle +27 -0
  19. package/nitrogen/generated/android/NitroAliPushOnLoad.cpp +58 -0
  20. package/nitrogen/generated/android/NitroAliPushOnLoad.hpp +34 -0
  21. package/nitrogen/generated/android/c++/JAliPushAppState.hpp +61 -0
  22. package/nitrogen/generated/android/c++/JAliPushMessage.hpp +98 -0
  23. package/nitrogen/generated/android/c++/JAliPushMessageType.hpp +58 -0
  24. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  25. package/nitrogen/generated/android/c++/JFunc_void_AliPushMessage.hpp +87 -0
  26. package/nitrogen/generated/android/c++/JHybridAliPushPluginSpec.cpp +338 -0
  27. package/nitrogen/generated/android/c++/JHybridAliPushPluginSpec.hpp +78 -0
  28. package/nitrogen/generated/android/c++/JVariant_Double_String.cpp +26 -0
  29. package/nitrogen/generated/android/c++/JVariant_Double_String.hpp +68 -0
  30. package/nitrogen/generated/android/c++/JVariant_NullType_AliPushMessage.cpp +26 -0
  31. package/nitrogen/generated/android/c++/JVariant_NullType_AliPushMessage.hpp +80 -0
  32. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  33. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/AliPushAppState.kt +24 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/AliPushMessage.kt +91 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/AliPushMessageType.kt +23 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/Func_void.kt +78 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/Func_void_AliPushMessage.kt +78 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/HybridAliPushPluginSpec.kt +123 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/NitroAliPushOnLoad.kt +35 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/Variant_Double_String.kt +62 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/Variant_NullType_AliPushMessage.kt +62 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/alipush/Variant_NullType_String.kt +62 -0
  44. package/nitrogen/generated/ios/NitroAliPush+autolinking.rb +62 -0
  45. package/nitrogen/generated/ios/NitroAliPush-Swift-Cxx-Bridge.cpp +89 -0
  46. package/nitrogen/generated/ios/NitroAliPush-Swift-Cxx-Bridge.hpp +531 -0
  47. package/nitrogen/generated/ios/NitroAliPush-Swift-Cxx-Umbrella.hpp +60 -0
  48. package/nitrogen/generated/ios/NitroAliPushAutolinking.mm +33 -0
  49. package/nitrogen/generated/ios/NitroAliPushAutolinking.swift +26 -0
  50. package/nitrogen/generated/ios/c++/HybridAliPushPluginSpecSwift.cpp +11 -0
  51. package/nitrogen/generated/ios/c++/HybridAliPushPluginSpecSwift.hpp +217 -0
  52. package/nitrogen/generated/ios/swift/AliPushAppState.swift +44 -0
  53. package/nitrogen/generated/ios/swift/AliPushMessage.swift +191 -0
  54. package/nitrogen/generated/ios/swift/AliPushMessageType.swift +40 -0
  55. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  56. package/nitrogen/generated/ios/swift/Func_void_AliPushMessage.swift +46 -0
  57. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  58. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  59. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  60. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  61. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__AliPushMessage_.swift +58 -0
  62. package/nitrogen/generated/ios/swift/HybridAliPushPluginSpec.swift +70 -0
  63. package/nitrogen/generated/ios/swift/HybridAliPushPluginSpec_cxx.swift +476 -0
  64. package/nitrogen/generated/ios/swift/Variant_Double_String.swift +30 -0
  65. package/nitrogen/generated/ios/swift/Variant_NullType_AliPushMessage.swift +30 -0
  66. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +30 -0
  67. package/nitrogen/generated/shared/c++/AliPushAppState.hpp +80 -0
  68. package/nitrogen/generated/shared/c++/AliPushMessage.hpp +123 -0
  69. package/nitrogen/generated/shared/c++/AliPushMessageType.hpp +76 -0
  70. package/nitrogen/generated/shared/c++/HybridAliPushPluginSpec.cpp +36 -0
  71. package/nitrogen/generated/shared/c++/HybridAliPushPluginSpec.hpp +85 -0
  72. package/package.json +61 -4
  73. package/react-native-nitro-ali-push.podspec +29 -0
  74. package/src/index.ts +284 -0
  75. package/src/specs/AliPushPlugin.nitro.ts +104 -0
  76. package/src/types.ts +117 -0
@@ -0,0 +1,123 @@
1
+ ///
2
+ /// AliPushMessage.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 `AliPushMessageType` to properly resolve imports.
32
+ namespace margelo::nitro::alipush { enum class AliPushMessageType; }
33
+ // Forward declaration of `AliPushAppState` to properly resolve imports.
34
+ namespace margelo::nitro::alipush { enum class AliPushAppState; }
35
+
36
+ #include <string>
37
+ #include <optional>
38
+ #include <NitroModules/AnyMap.hpp>
39
+ #include "AliPushMessageType.hpp"
40
+ #include "AliPushAppState.hpp"
41
+ #include <variant>
42
+
43
+ namespace margelo::nitro::alipush {
44
+
45
+ /**
46
+ * A struct which can be represented as a JavaScript object (AliPushMessage).
47
+ */
48
+ struct AliPushMessage final {
49
+ public:
50
+ std::optional<std::string> title SWIFT_PRIVATE;
51
+ std::optional<std::string> subtitle SWIFT_PRIVATE;
52
+ std::optional<std::string> body SWIFT_PRIVATE;
53
+ std::optional<double> badge SWIFT_PRIVATE;
54
+ std::optional<std::shared_ptr<AnyMap>> extras SWIFT_PRIVATE;
55
+ std::optional<AliPushMessageType> type SWIFT_PRIVATE;
56
+ std::optional<std::string> actionIdentifier SWIFT_PRIVATE;
57
+ std::optional<AliPushAppState> appState SWIFT_PRIVATE;
58
+ std::optional<std::variant<double, std::string>> date SWIFT_PRIVATE;
59
+
60
+ public:
61
+ AliPushMessage() = default;
62
+ explicit AliPushMessage(std::optional<std::string> title, std::optional<std::string> subtitle, std::optional<std::string> body, std::optional<double> badge, std::optional<std::shared_ptr<AnyMap>> extras, std::optional<AliPushMessageType> type, std::optional<std::string> actionIdentifier, std::optional<AliPushAppState> appState, std::optional<std::variant<double, std::string>> date): title(title), subtitle(subtitle), body(body), badge(badge), extras(extras), type(type), actionIdentifier(actionIdentifier), appState(appState), date(date) {}
63
+
64
+ public:
65
+ friend bool operator==(const AliPushMessage& lhs, const AliPushMessage& rhs) = default;
66
+ };
67
+
68
+ } // namespace margelo::nitro::alipush
69
+
70
+ namespace margelo::nitro {
71
+
72
+ // C++ AliPushMessage <> JS AliPushMessage (object)
73
+ template <>
74
+ struct JSIConverter<margelo::nitro::alipush::AliPushMessage> final {
75
+ static inline margelo::nitro::alipush::AliPushMessage fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
76
+ jsi::Object obj = arg.asObject(runtime);
77
+ return margelo::nitro::alipush::AliPushMessage(
78
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
79
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitle"))),
80
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body"))),
81
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "badge"))),
82
+ JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extras"))),
83
+ JSIConverter<std::optional<margelo::nitro::alipush::AliPushMessageType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
84
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionIdentifier"))),
85
+ JSIConverter<std::optional<margelo::nitro::alipush::AliPushAppState>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "appState"))),
86
+ JSIConverter<std::optional<std::variant<double, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "date")))
87
+ );
88
+ }
89
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::alipush::AliPushMessage& arg) {
90
+ jsi::Object obj(runtime);
91
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
92
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "subtitle"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subtitle));
93
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "body"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.body));
94
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "badge"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.badge));
95
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "extras"), JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::toJSI(runtime, arg.extras));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<std::optional<margelo::nitro::alipush::AliPushMessageType>>::toJSI(runtime, arg.type));
97
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "actionIdentifier"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.actionIdentifier));
98
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "appState"), JSIConverter<std::optional<margelo::nitro::alipush::AliPushAppState>>::toJSI(runtime, arg.appState));
99
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "date"), JSIConverter<std::optional<std::variant<double, std::string>>>::toJSI(runtime, arg.date));
100
+ return obj;
101
+ }
102
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
103
+ if (!value.isObject()) {
104
+ return false;
105
+ }
106
+ jsi::Object obj = value.getObject(runtime);
107
+ if (!nitro::isPlainObject(runtime, obj)) {
108
+ return false;
109
+ }
110
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
111
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subtitle")))) return false;
112
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body")))) return false;
113
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "badge")))) return false;
114
+ if (!JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "extras")))) return false;
115
+ if (!JSIConverter<std::optional<margelo::nitro::alipush::AliPushMessageType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
116
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionIdentifier")))) return false;
117
+ if (!JSIConverter<std::optional<margelo::nitro::alipush::AliPushAppState>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "appState")))) return false;
118
+ if (!JSIConverter<std::optional<std::variant<double, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "date")))) return false;
119
+ return true;
120
+ }
121
+ };
122
+
123
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// AliPushMessageType.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::alipush {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (AliPushMessageType).
30
+ */
31
+ enum class AliPushMessageType {
32
+ NOTIFICATION SWIFT_NAME(notification) = 0,
33
+ MESSAGE SWIFT_NAME(message) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::alipush
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ AliPushMessageType <> JS AliPushMessageType (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::alipush::AliPushMessageType> final {
43
+ static inline margelo::nitro::alipush::AliPushMessageType 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("notification"): return margelo::nitro::alipush::AliPushMessageType::NOTIFICATION;
47
+ case hashString("message"): return margelo::nitro::alipush::AliPushMessageType::MESSAGE;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AliPushMessageType - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::alipush::AliPushMessageType arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::alipush::AliPushMessageType::NOTIFICATION: return JSIConverter<std::string>::toJSI(runtime, "notification");
55
+ case margelo::nitro::alipush::AliPushMessageType::MESSAGE: return JSIConverter<std::string>::toJSI(runtime, "message");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert AliPushMessageType 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("notification"):
68
+ case hashString("message"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// HybridAliPushPluginSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridAliPushPluginSpec.hpp"
9
+
10
+ namespace margelo::nitro::alipush {
11
+
12
+ void HybridAliPushPluginSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("initPush", &HybridAliPushPluginSpec::initPush);
18
+ prototype.registerHybridMethod("getDeviceId", &HybridAliPushPluginSpec::getDeviceId);
19
+ prototype.registerHybridMethod("bindAccount", &HybridAliPushPluginSpec::bindAccount);
20
+ prototype.registerHybridMethod("unbindAccount", &HybridAliPushPluginSpec::unbindAccount);
21
+ prototype.registerHybridMethod("bindTag", &HybridAliPushPluginSpec::bindTag);
22
+ prototype.registerHybridMethod("unbindTag", &HybridAliPushPluginSpec::unbindTag);
23
+ prototype.registerHybridMethod("listTags", &HybridAliPushPluginSpec::listTags);
24
+ prototype.registerHybridMethod("addAlias", &HybridAliPushPluginSpec::addAlias);
25
+ prototype.registerHybridMethod("removeAlias", &HybridAliPushPluginSpec::removeAlias);
26
+ prototype.registerHybridMethod("listAliases", &HybridAliPushPluginSpec::listAliases);
27
+ prototype.registerHybridMethod("setApplicationIconBadgeNumber", &HybridAliPushPluginSpec::setApplicationIconBadgeNumber);
28
+ prototype.registerHybridMethod("getApplicationIconBadgeNumber", &HybridAliPushPluginSpec::getApplicationIconBadgeNumber);
29
+ prototype.registerHybridMethod("getInitialMessage", &HybridAliPushPluginSpec::getInitialMessage);
30
+ prototype.registerHybridMethod("getAuthorizationStatus", &HybridAliPushPluginSpec::getAuthorizationStatus);
31
+ prototype.registerHybridMethod("syncBadgeNum", &HybridAliPushPluginSpec::syncBadgeNum);
32
+ prototype.registerHybridMethod("addListener", &HybridAliPushPluginSpec::addListener);
33
+ });
34
+ }
35
+
36
+ } // namespace margelo::nitro::alipush
@@ -0,0 +1,85 @@
1
+ ///
2
+ /// HybridAliPushPluginSpec.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 `AliPushMessage` to properly resolve imports.
17
+ namespace margelo::nitro::alipush { struct AliPushMessage; }
18
+
19
+ #include <NitroModules/Promise.hpp>
20
+ #include <string>
21
+ #include <vector>
22
+ #include <NitroModules/Null.hpp>
23
+ #include <variant>
24
+ #include <optional>
25
+ #include "AliPushMessage.hpp"
26
+ #include <functional>
27
+
28
+ namespace margelo::nitro::alipush {
29
+
30
+ using namespace margelo::nitro;
31
+
32
+ /**
33
+ * An abstract base class for `AliPushPlugin`
34
+ * Inherit this class to create instances of `HybridAliPushPluginSpec` in C++.
35
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
36
+ * @example
37
+ * ```cpp
38
+ * class HybridAliPushPlugin: public HybridAliPushPluginSpec {
39
+ * public:
40
+ * HybridAliPushPlugin(...): HybridObject(TAG) { ... }
41
+ * // ...
42
+ * };
43
+ * ```
44
+ */
45
+ class HybridAliPushPluginSpec: public virtual HybridObject {
46
+ public:
47
+ // Constructor
48
+ explicit HybridAliPushPluginSpec(): HybridObject(TAG) { }
49
+
50
+ // Destructor
51
+ ~HybridAliPushPluginSpec() override = default;
52
+
53
+ public:
54
+ // Properties
55
+
56
+
57
+ public:
58
+ // Methods
59
+ virtual std::shared_ptr<Promise<void>> initPush(const std::string& appKey, const std::string& appSecret) = 0;
60
+ virtual std::shared_ptr<Promise<std::string>> getDeviceId() = 0;
61
+ virtual std::shared_ptr<Promise<void>> bindAccount(const std::string& account) = 0;
62
+ virtual std::shared_ptr<Promise<void>> unbindAccount() = 0;
63
+ virtual std::shared_ptr<Promise<void>> bindTag(double target, const std::vector<std::string>& tags, const std::optional<std::variant<nitro::NullType, std::string>>& alias) = 0;
64
+ virtual std::shared_ptr<Promise<void>> unbindTag(double target, const std::vector<std::string>& tags, const std::optional<std::variant<nitro::NullType, std::string>>& alias) = 0;
65
+ virtual std::shared_ptr<Promise<std::string>> listTags(double target) = 0;
66
+ virtual std::shared_ptr<Promise<void>> addAlias(const std::string& alias) = 0;
67
+ virtual std::shared_ptr<Promise<void>> removeAlias(const std::string& alias) = 0;
68
+ virtual std::shared_ptr<Promise<std::string>> listAliases() = 0;
69
+ virtual std::shared_ptr<Promise<void>> setApplicationIconBadgeNumber(double badge) = 0;
70
+ virtual std::shared_ptr<Promise<double>> getApplicationIconBadgeNumber() = 0;
71
+ virtual std::shared_ptr<Promise<std::variant<nitro::NullType, AliPushMessage>>> getInitialMessage() = 0;
72
+ virtual std::shared_ptr<Promise<bool>> getAuthorizationStatus() = 0;
73
+ virtual std::shared_ptr<Promise<void>> syncBadgeNum(double badge) = 0;
74
+ virtual std::function<void()> addListener(const std::function<void(const AliPushMessage& /* message */)>& listener) = 0;
75
+
76
+ protected:
77
+ // Hybrid Setup
78
+ void loadHybridMethods() override;
79
+
80
+ protected:
81
+ // Tag for logging
82
+ static constexpr auto TAG = "AliPushPlugin";
83
+ };
84
+
85
+ } // namespace margelo::nitro::alipush
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "react-native-nitro-ali-push",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "React Native wrapper for Alibaba Cloud Push (阿里云移动推送), built with Nitro Modules (swift/kotlin HybridObject).",
5
+ "main": "lib/index.js",
6
+ "module": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "react-native": "src/index.ts",
9
+ "source": "src/index.ts",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "nitrogen",
16
+ "*.podspec",
17
+ "!**/__tests__",
18
+ "!**/__fixtures__",
19
+ "!**/__mocks__"
20
+ ],
21
+ "scripts": {
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
24
+ "build": "tsc -p tsconfig.build.json",
25
+ "codegen": "nitrogen",
26
+ "prepack": "npm run build"
27
+ },
28
+ "keywords": [
29
+ "react-native",
30
+ "ali-push",
31
+ "aliyun",
32
+ "alibaba",
33
+ "push",
34
+ "notification",
35
+ "nitro",
36
+ "nitro-modules"
37
+ ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/hengkx/react-native-nitro-ali-push.git"
41
+ },
42
+ "homepage": "https://github.com/hengkx/react-native-nitro-ali-push",
43
+ "bugs": {
44
+ "url": "https://github.com/hengkx/react-native-nitro-ali-push/issues"
45
+ },
46
+ "license": "MIT",
47
+ "author": "hengkx <ycxzhkx@gmail.com>",
48
+ "engines": {
49
+ "node": ">= 18"
50
+ },
51
+ "peerDependencies": {
52
+ "react": "*",
53
+ "react-native": ">=0.76.0",
54
+ "react-native-nitro-modules": ">=0.37.0"
55
+ },
56
+ "devDependencies": {
57
+ "nitrogen": "0.37.1",
58
+ "react-native-nitro-modules": "0.37.1",
59
+ "@types/react": "^18.2.0",
60
+ "react": "18.2.0",
61
+ "typescript": "^5.4.0"
62
+ }
63
+ }
@@ -0,0 +1,29 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-nitro-ali-push"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = "https://github.com/hengkx/react-native-nitro-ali-push"
10
+ s.license = "MIT"
11
+ s.authors = { "hengkx" => "ycxzhkx@gmail.com" }
12
+
13
+ s.platforms = { :ios => "13.0", :tvos => "13.0" }
14
+ s.source = { :git => "https://github.com/hengkx/react-native-nitro-ali-push.git", :tag => "v#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{swift}"
17
+ s.requires_arc = true
18
+ s.swift_version = "5.0"
19
+
20
+ # 引入 Nitro 生成的原生文件与构建配置(C++ 互操作、NitroModules 依赖等)。
21
+ load 'nitrogen/generated/ios/NitroAliPush+autolinking.rb'
22
+ add_nitrogen_files(s)
23
+
24
+ # 阿里云推送 SDK(CloudPushSDK.framework)。
25
+ # 推荐方式:放到本库 ios/ 目录下,并取消下面注释;或改为你自己的引入方式。
26
+ # s.vendored_frameworks = 'ios/CloudPushSDK.framework'
27
+
28
+ s.dependency "React-Core"
29
+ end