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
|
@@ -125,51 +125,21 @@ open class HybridPushSignalSpec_cxx {
|
|
|
125
125
|
|
|
126
126
|
// Methods
|
|
127
127
|
@inline(__always)
|
|
128
|
-
public final func initialize(config: AndroidFirebaseConfig) -> bridge.
|
|
128
|
+
public final func initialize(config: AndroidFirebaseConfig) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
129
129
|
do {
|
|
130
|
-
try self.__implementation.initialize(config: config)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return bridge.create_Result_void_(__exceptionPtr)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@inline(__always)
|
|
139
|
-
public final func getPermissionStatus() -> bridge.Result_std__shared_ptr_Promise_PermissionStatus___ {
|
|
140
|
-
do {
|
|
141
|
-
let __result = try self.__implementation.getPermissionStatus()
|
|
142
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionStatus__ in
|
|
143
|
-
let __promise = bridge.create_std__shared_ptr_Promise_PermissionStatus__()
|
|
144
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionStatus__(__promise)
|
|
145
|
-
__result
|
|
146
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
147
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
148
|
-
return __promise
|
|
149
|
-
}()
|
|
150
|
-
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__resultCpp)
|
|
151
|
-
} catch (let __error) {
|
|
152
|
-
let __exceptionPtr = __error.toCpp()
|
|
153
|
-
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__exceptionPtr)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@inline(__always)
|
|
158
|
-
public final func requestPermission() -> bridge.Result_std__shared_ptr_Promise_PermissionStatus___ {
|
|
159
|
-
do {
|
|
160
|
-
let __result = try self.__implementation.requestPermission()
|
|
161
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionStatus__ in
|
|
162
|
-
let __promise = bridge.create_std__shared_ptr_Promise_PermissionStatus__()
|
|
163
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionStatus__(__promise)
|
|
130
|
+
let __result = try self.__implementation.initialize(config: config)
|
|
131
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
132
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
133
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
164
134
|
__result
|
|
165
|
-
.then({ __result in __promiseHolder.resolve(
|
|
135
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
166
136
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
167
137
|
return __promise
|
|
168
138
|
}()
|
|
169
|
-
return bridge.
|
|
139
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
170
140
|
} catch (let __error) {
|
|
171
141
|
let __exceptionPtr = __error.toCpp()
|
|
172
|
-
return bridge.
|
|
142
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
173
143
|
}
|
|
174
144
|
}
|
|
175
145
|
|
|
@@ -19,8 +19,8 @@ public extension PushPlatform {
|
|
|
19
19
|
switch string {
|
|
20
20
|
case "ios":
|
|
21
21
|
self = .ios
|
|
22
|
-
case "
|
|
23
|
-
self = .
|
|
22
|
+
case "android_os":
|
|
23
|
+
self = .androidOs
|
|
24
24
|
default:
|
|
25
25
|
return nil
|
|
26
26
|
}
|
|
@@ -33,8 +33,8 @@ public extension PushPlatform {
|
|
|
33
33
|
switch self {
|
|
34
34
|
case .ios:
|
|
35
35
|
return "ios"
|
|
36
|
-
case .
|
|
37
|
-
return "
|
|
36
|
+
case .androidOs:
|
|
37
|
+
return "android_os"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -40,14 +40,14 @@ namespace margelo::nitro::pushsignal {
|
|
|
40
40
|
*/
|
|
41
41
|
struct AndroidFirebaseConfig final {
|
|
42
42
|
public:
|
|
43
|
-
std::optional<std::string>
|
|
44
|
-
std::optional<std::string>
|
|
45
|
-
std::optional<std::string>
|
|
46
|
-
std::optional<std::string>
|
|
43
|
+
std::optional<std::string> project_id SWIFT_PRIVATE;
|
|
44
|
+
std::optional<std::string> mobilesdk_app_id SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> current_key SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::string> project_number SWIFT_PRIVATE;
|
|
47
47
|
|
|
48
48
|
public:
|
|
49
49
|
AndroidFirebaseConfig() = default;
|
|
50
|
-
explicit AndroidFirebaseConfig(std::optional<std::string>
|
|
50
|
+
explicit AndroidFirebaseConfig(std::optional<std::string> project_id, std::optional<std::string> mobilesdk_app_id, std::optional<std::string> current_key, std::optional<std::string> project_number): project_id(project_id), mobilesdk_app_id(mobilesdk_app_id), current_key(current_key), project_number(project_number) {}
|
|
51
51
|
|
|
52
52
|
public:
|
|
53
53
|
friend bool operator==(const AndroidFirebaseConfig& lhs, const AndroidFirebaseConfig& rhs) = default;
|
|
@@ -63,18 +63,18 @@ namespace margelo::nitro {
|
|
|
63
63
|
static inline margelo::nitro::pushsignal::AndroidFirebaseConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
64
|
jsi::Object obj = arg.asObject(runtime);
|
|
65
65
|
return margelo::nitro::pushsignal::AndroidFirebaseConfig(
|
|
66
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
67
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
68
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
69
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
66
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "project_id"))),
|
|
67
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mobilesdk_app_id"))),
|
|
68
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "current_key"))),
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "project_number")))
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pushsignal::AndroidFirebaseConfig& arg) {
|
|
73
73
|
jsi::Object obj(runtime);
|
|
74
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
75
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
76
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
77
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "project_id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.project_id));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mobilesdk_app_id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mobilesdk_app_id));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "current_key"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.current_key));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "project_number"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.project_number));
|
|
78
78
|
return obj;
|
|
79
79
|
}
|
|
80
80
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -85,10 +85,10 @@ namespace margelo::nitro {
|
|
|
85
85
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
89
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
90
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
91
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
88
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "project_id")))) return false;
|
|
89
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mobilesdk_app_id")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "current_key")))) return false;
|
|
91
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "project_number")))) return false;
|
|
92
92
|
return true;
|
|
93
93
|
}
|
|
94
94
|
};
|
|
@@ -15,8 +15,6 @@ namespace margelo::nitro::pushsignal {
|
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("initialize", &HybridPushSignalSpec::initialize);
|
|
18
|
-
prototype.registerHybridMethod("getPermissionStatus", &HybridPushSignalSpec::getPermissionStatus);
|
|
19
|
-
prototype.registerHybridMethod("requestPermission", &HybridPushSignalSpec::requestPermission);
|
|
20
18
|
prototype.registerHybridMethod("getCredentials", &HybridPushSignalSpec::getCredentials);
|
|
21
19
|
prototype.registerHybridMethod("setOnMessage", &HybridPushSignalSpec::setOnMessage);
|
|
22
20
|
prototype.registerHybridMethod("setOnNotificationPress", &HybridPushSignalSpec::setOnNotificationPress);
|
|
@@ -15,16 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
// Forward declaration of `AndroidFirebaseConfig` to properly resolve imports.
|
|
17
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
18
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
22
20
|
// Forward declaration of `PushMessage` to properly resolve imports.
|
|
23
21
|
namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
24
22
|
|
|
25
|
-
#include "AndroidFirebaseConfig.hpp"
|
|
26
|
-
#include "PermissionStatus.hpp"
|
|
27
23
|
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include "AndroidFirebaseConfig.hpp"
|
|
28
25
|
#include "PushCredentials.hpp"
|
|
29
26
|
#include "PushMessage.hpp"
|
|
30
27
|
#include <functional>
|
|
@@ -60,9 +57,7 @@ namespace margelo::nitro::pushsignal {
|
|
|
60
57
|
|
|
61
58
|
public:
|
|
62
59
|
// 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;
|
|
60
|
+
virtual std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) = 0;
|
|
66
61
|
virtual std::shared_ptr<Promise<PushCredentials>> getCredentials() = 0;
|
|
67
62
|
virtual void setOnMessage(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
|
|
68
63
|
virtual void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
|
|
@@ -30,7 +30,7 @@ namespace margelo::nitro::pushsignal {
|
|
|
30
30
|
*/
|
|
31
31
|
enum class PushPlatform {
|
|
32
32
|
IOS SWIFT_NAME(ios) = 0,
|
|
33
|
-
|
|
33
|
+
ANDROID_OS SWIFT_NAME(androidOs) = 1,
|
|
34
34
|
} CLOSED_ENUM;
|
|
35
35
|
|
|
36
36
|
} // namespace margelo::nitro::pushsignal
|
|
@@ -44,7 +44,7 @@ namespace margelo::nitro {
|
|
|
44
44
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
45
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
46
|
case hashString("ios"): return margelo::nitro::pushsignal::PushPlatform::IOS;
|
|
47
|
-
case hashString("
|
|
47
|
+
case hashString("android_os"): return margelo::nitro::pushsignal::PushPlatform::ANDROID_OS;
|
|
48
48
|
default: [[unlikely]]
|
|
49
49
|
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PushPlatform - invalid value!");
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ namespace margelo::nitro {
|
|
|
52
52
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pushsignal::PushPlatform arg) {
|
|
53
53
|
switch (arg) {
|
|
54
54
|
case margelo::nitro::pushsignal::PushPlatform::IOS: return JSIConverter<std::string>::toJSI(runtime, "ios");
|
|
55
|
-
case margelo::nitro::pushsignal::PushPlatform::
|
|
55
|
+
case margelo::nitro::pushsignal::PushPlatform::ANDROID_OS: return JSIConverter<std::string>::toJSI(runtime, "android_os");
|
|
56
56
|
default: [[unlikely]]
|
|
57
57
|
throw std::invalid_argument("Cannot convert PushPlatform to JS - invalid value: "
|
|
58
58
|
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
@@ -65,7 +65,7 @@ namespace margelo::nitro {
|
|
|
65
65
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
66
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
67
|
case hashString("ios"):
|
|
68
|
-
case hashString("
|
|
68
|
+
case hashString("android_os"):
|
|
69
69
|
return true;
|
|
70
70
|
default:
|
|
71
71
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-push-signal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Push",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -184,4 +184,4 @@
|
|
|
184
184
|
],
|
|
185
185
|
"version": "0.63.0"
|
|
186
186
|
}
|
|
187
|
-
}
|
|
187
|
+
}
|
package/src/PushSignal.nitro.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export type PushPlatform = 'ios' | '
|
|
3
|
+
/** JS/C++ name cannot be `android`: NDK defines `-DANDROID` and breaks the generated enum. */
|
|
4
|
+
export type PushPlatform = 'ios' | 'android_os';
|
|
5
5
|
export type PushEnvironment = 'sandbox' | 'production';
|
|
6
6
|
|
|
7
7
|
export interface PushCredentials {
|
|
@@ -18,19 +18,17 @@ export interface PushMessage {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface AndroidFirebaseConfig {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
project_id?: string;
|
|
22
|
+
mobilesdk_app_id?: string;
|
|
23
|
+
current_key?: string;
|
|
24
|
+
project_number?: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface PushSignal extends HybridObject<{
|
|
28
28
|
ios: 'swift';
|
|
29
29
|
android: 'kotlin';
|
|
30
30
|
}> {
|
|
31
|
-
initialize(config: AndroidFirebaseConfig): void
|
|
32
|
-
getPermissionStatus(): Promise<PermissionStatus>;
|
|
33
|
-
requestPermission(): Promise<PermissionStatus>;
|
|
31
|
+
initialize(config: AndroidFirebaseConfig): Promise<void>;
|
|
34
32
|
getCredentials(): Promise<PushCredentials>;
|
|
35
33
|
setOnMessage(callback: (message: PushMessage) => void): void;
|
|
36
34
|
setOnNotificationPress(callback: (message: PushMessage) => void): void;
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
AndroidFirebaseConfig,
|
|
3
|
-
PermissionStatus,
|
|
4
3
|
PushCredentials,
|
|
5
4
|
PushEnvironment,
|
|
6
5
|
PushMessage,
|
|
@@ -8,9 +7,7 @@ export type {
|
|
|
8
7
|
} from './PushSignal.nitro';
|
|
9
8
|
export {
|
|
10
9
|
getCredentials,
|
|
11
|
-
getPermissionStatus,
|
|
12
10
|
initialize,
|
|
13
11
|
onMessage,
|
|
14
12
|
onNotificationPress,
|
|
15
|
-
requestPermission,
|
|
16
13
|
} from './pushSignal';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
2
|
import type {
|
|
3
3
|
AndroidFirebaseConfig,
|
|
4
|
-
PermissionStatus,
|
|
5
4
|
PushCredentials,
|
|
6
5
|
PushMessage,
|
|
7
6
|
PushSignal,
|
|
@@ -30,16 +29,8 @@ function bindNativeCallbacks() {
|
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export function initialize(config: AndroidFirebaseConfig = {}): void {
|
|
34
|
-
PushSignalHybridObject.initialize(config);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getPermissionStatus(): Promise<PermissionStatus> {
|
|
38
|
-
return PushSignalHybridObject.getPermissionStatus();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function requestPermission(): Promise<PermissionStatus> {
|
|
42
|
-
return PushSignalHybridObject.requestPermission();
|
|
32
|
+
export function initialize(config: AndroidFirebaseConfig = {}): Promise<void> {
|
|
33
|
+
return PushSignalHybridObject.initialize(config);
|
|
43
34
|
}
|
|
44
35
|
|
|
45
36
|
export function getCredentials(): Promise<PushCredentials> {
|
package/src/pushSignal.tsx
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AndroidFirebaseConfig,
|
|
3
|
-
PermissionStatus,
|
|
4
3
|
PushCredentials,
|
|
5
4
|
PushMessage,
|
|
6
5
|
} from './PushSignal.nitro';
|
|
7
6
|
|
|
8
|
-
export function initialize(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return 'denied';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function requestPermission(): Promise<PermissionStatus> {
|
|
15
|
-
return 'denied';
|
|
16
|
-
}
|
|
7
|
+
export async function initialize(
|
|
8
|
+
_config: AndroidFirebaseConfig = {}
|
|
9
|
+
): Promise<void> {}
|
|
17
10
|
|
|
18
11
|
export async function getCredentials(): Promise<PushCredentials> {
|
|
19
12
|
throw new Error('Push credentials are not supported on web');
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JPermissionStatus.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#include <fbjni/fbjni.h>
|
|
11
|
-
#include "PermissionStatus.hpp"
|
|
12
|
-
|
|
13
|
-
namespace margelo::nitro::pushsignal {
|
|
14
|
-
|
|
15
|
-
using namespace facebook;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The C++ JNI bridge between the C++ enum "PermissionStatus" and the Kotlin enum "PermissionStatus".
|
|
19
|
-
*/
|
|
20
|
-
struct JPermissionStatus final: public jni::JavaClass<JPermissionStatus> {
|
|
21
|
-
public:
|
|
22
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PermissionStatus;";
|
|
23
|
-
|
|
24
|
-
public:
|
|
25
|
-
/**
|
|
26
|
-
* Convert this Java/Kotlin-based enum to the C++ enum PermissionStatus.
|
|
27
|
-
*/
|
|
28
|
-
[[maybe_unused]]
|
|
29
|
-
[[nodiscard]]
|
|
30
|
-
PermissionStatus toCpp() const {
|
|
31
|
-
static const auto clazz = javaClassStatic();
|
|
32
|
-
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
-
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
-
return static_cast<PermissionStatus>(ordinal);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public:
|
|
38
|
-
/**
|
|
39
|
-
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
-
*/
|
|
41
|
-
[[maybe_unused]]
|
|
42
|
-
static jni::alias_ref<JPermissionStatus> fromCpp(PermissionStatus value) {
|
|
43
|
-
static const auto clazz = javaClassStatic();
|
|
44
|
-
switch (value) {
|
|
45
|
-
case PermissionStatus::AUTHORIZED:
|
|
46
|
-
static const auto fieldAUTHORIZED = clazz->getStaticField<JPermissionStatus>("AUTHORIZED");
|
|
47
|
-
return clazz->getStaticFieldValue(fieldAUTHORIZED);
|
|
48
|
-
case PermissionStatus::DENIED:
|
|
49
|
-
static const auto fieldDENIED = clazz->getStaticField<JPermissionStatus>("DENIED");
|
|
50
|
-
return clazz->getStaticFieldValue(fieldDENIED);
|
|
51
|
-
case PermissionStatus::NOTDETERMINED:
|
|
52
|
-
static const auto fieldNOTDETERMINED = clazz->getStaticField<JPermissionStatus>("NOTDETERMINED");
|
|
53
|
-
return clazz->getStaticFieldValue(fieldNOTDETERMINED);
|
|
54
|
-
default:
|
|
55
|
-
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
-
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
} // namespace margelo::nitro::pushsignal
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// PermissionStatus.kt
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
package com.margelo.nitro.pushsignal
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Represents the JavaScript enum/union "PermissionStatus".
|
|
15
|
-
*/
|
|
16
|
-
@DoNotStrip
|
|
17
|
-
@Keep
|
|
18
|
-
enum class PermissionStatus(@DoNotStrip @Keep val value: Int) {
|
|
19
|
-
AUTHORIZED(0),
|
|
20
|
-
DENIED(1),
|
|
21
|
-
NOTDETERMINED(2);
|
|
22
|
-
|
|
23
|
-
companion object
|
|
24
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// PermissionStatus.swift
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Represents the JS union `PermissionStatus`, backed by a C++ enum.
|
|
10
|
-
*/
|
|
11
|
-
public typealias PermissionStatus = margelo.nitro.pushsignal.PermissionStatus
|
|
12
|
-
|
|
13
|
-
public extension PermissionStatus {
|
|
14
|
-
/**
|
|
15
|
-
* Get a PermissionStatus for the given String value, or
|
|
16
|
-
* return `nil` if the given value was invalid/unknown.
|
|
17
|
-
*/
|
|
18
|
-
init?(fromString string: String) {
|
|
19
|
-
switch string {
|
|
20
|
-
case "authorized":
|
|
21
|
-
self = .authorized
|
|
22
|
-
case "denied":
|
|
23
|
-
self = .denied
|
|
24
|
-
case "notDetermined":
|
|
25
|
-
self = .notdetermined
|
|
26
|
-
default:
|
|
27
|
-
return nil
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the String value this PermissionStatus represents.
|
|
33
|
-
*/
|
|
34
|
-
var stringValue: String {
|
|
35
|
-
switch self {
|
|
36
|
-
case .authorized:
|
|
37
|
-
return "authorized"
|
|
38
|
-
case .denied:
|
|
39
|
-
return "denied"
|
|
40
|
-
case .notdetermined:
|
|
41
|
-
return "notDetermined"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
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
|