react-native-push-signal 0.1.0 → 0.1.2
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 +36 -19
- package/README.ru.md +36 -19
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +10 -16
- package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +156 -109
- package/ios/PushSignal.swift +3 -12
- package/ios/PushSignalCenter.swift +36 -41
- 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 +10 -9
- package/lib/module/pushSignal.native.js.map +1 -1
- package/lib/typescript/src/PushSignal.nitro.d.ts +9 -10
- 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 +3 -5
- package/lib/typescript/src/pushSignal.d.ts.map +1 -1
- package/lib/typescript/src/pushSignal.native.d.ts +3 -5
- 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++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.hpp +128 -0
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +12 -35
- package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +2 -4
- 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/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +3 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +1 -1
- package/nitrogen/generated/android/pushsignalOnLoad.cpp +2 -0
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +30 -5
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +140 -52
- package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +0 -3
- package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +3 -20
- package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +17 -17
- package/nitrogen/generated/ios/swift/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.swift +61 -0
- package/nitrogen/generated/ios/swift/{Func_void_PermissionStatus.swift → Func_void.swift} +11 -11
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_Promise_bool__.swift +66 -0
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +2 -4
- package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +34 -43
- 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 +3 -8
- package/nitrogen/generated/shared/c++/PushPlatform.hpp +4 -4
- package/package.json +2 -2
- package/src/PushSignal.nitro.ts +12 -10
- package/src/index.tsx +1 -3
- package/src/pushSignal.native.tsx +17 -17
- package/src/pushSignal.tsx +5 -13
- 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
|
@@ -18,27 +18,27 @@ public extension AndroidFirebaseConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `AndroidFirebaseConfig`.
|
|
20
20
|
*/
|
|
21
|
-
init(
|
|
21
|
+
init(project_id: String?, mobilesdk_app_id: String?, current_key: String?, project_number: String?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
-
if let __unwrappedValue =
|
|
23
|
+
if let __unwrappedValue = project_id {
|
|
24
24
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
25
|
} else {
|
|
26
26
|
return .init()
|
|
27
27
|
}
|
|
28
28
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
29
|
-
if let __unwrappedValue =
|
|
29
|
+
if let __unwrappedValue = mobilesdk_app_id {
|
|
30
30
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
31
31
|
} else {
|
|
32
32
|
return .init()
|
|
33
33
|
}
|
|
34
34
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
35
|
-
if let __unwrappedValue =
|
|
35
|
+
if let __unwrappedValue = current_key {
|
|
36
36
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
37
37
|
} else {
|
|
38
38
|
return .init()
|
|
39
39
|
}
|
|
40
40
|
}(), { () -> bridge.std__optional_std__string_ in
|
|
41
|
-
if let __unwrappedValue =
|
|
41
|
+
if let __unwrappedValue = project_number {
|
|
42
42
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
43
43
|
} else {
|
|
44
44
|
return .init()
|
|
@@ -47,10 +47,10 @@ public extension AndroidFirebaseConfig {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@inline(__always)
|
|
50
|
-
var
|
|
50
|
+
var project_id: String? {
|
|
51
51
|
return { () -> String? in
|
|
52
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
53
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
52
|
+
if bridge.has_value_std__optional_std__string_(self.__project_id) {
|
|
53
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__project_id)
|
|
54
54
|
return String(__unwrapped)
|
|
55
55
|
} else {
|
|
56
56
|
return nil
|
|
@@ -59,10 +59,10 @@ public extension AndroidFirebaseConfig {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
@inline(__always)
|
|
62
|
-
var
|
|
62
|
+
var mobilesdk_app_id: String? {
|
|
63
63
|
return { () -> String? in
|
|
64
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
65
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
64
|
+
if bridge.has_value_std__optional_std__string_(self.__mobilesdk_app_id) {
|
|
65
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__mobilesdk_app_id)
|
|
66
66
|
return String(__unwrapped)
|
|
67
67
|
} else {
|
|
68
68
|
return nil
|
|
@@ -71,10 +71,10 @@ public extension AndroidFirebaseConfig {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
@inline(__always)
|
|
74
|
-
var
|
|
74
|
+
var current_key: String? {
|
|
75
75
|
return { () -> String? in
|
|
76
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
77
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
76
|
+
if bridge.has_value_std__optional_std__string_(self.__current_key) {
|
|
77
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__current_key)
|
|
78
78
|
return String(__unwrapped)
|
|
79
79
|
} else {
|
|
80
80
|
return nil
|
|
@@ -83,10 +83,10 @@ public extension AndroidFirebaseConfig {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
@inline(__always)
|
|
86
|
-
var
|
|
86
|
+
var project_number: String? {
|
|
87
87
|
return { () -> String? in
|
|
88
|
-
if bridge.has_value_std__optional_std__string_(self.
|
|
89
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.
|
|
88
|
+
if bridge.has_value_std__optional_std__string_(self.__project_number) {
|
|
89
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__project_number)
|
|
90
90
|
return String(__unwrapped)
|
|
91
91
|
} else {
|
|
92
92
|
return nil
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ message: PushMessage) -> Promise<Promise<Bool>>` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
15
|
+
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ message: PushMessage) -> Promise<Promise<Bool>>
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ message: PushMessage) -> Promise<Promise<Bool>>) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(message: PushMessage) -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_bool____ {
|
|
25
|
+
let __result: Promise<Promise<Bool>> = self.closure(message)
|
|
26
|
+
return { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_bool____ in
|
|
27
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____()
|
|
28
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____(__promise)
|
|
29
|
+
__result
|
|
30
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
31
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
32
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
33
|
+
__result
|
|
34
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
35
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
36
|
+
return __promise
|
|
37
|
+
}()) })
|
|
38
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
39
|
+
return __promise
|
|
40
|
+
}()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
45
|
+
* This acquires one additional strong reference on the object!
|
|
46
|
+
*/
|
|
47
|
+
@inline(__always)
|
|
48
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
49
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Casts an unsafe pointer to a `Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage`.
|
|
54
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage>`.
|
|
55
|
+
* This removes one strong reference from the object!
|
|
56
|
+
*/
|
|
57
|
+
@inline(__always)
|
|
58
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage {
|
|
59
|
+
return Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage>.fromOpaque(pointer).takeRetainedValue()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// Func_void.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
import NitroModules
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Wraps a Swift `(
|
|
11
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
12
12
|
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
13
|
*/
|
|
14
|
-
public final class
|
|
14
|
+
public final class Func_void {
|
|
15
15
|
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
16
|
|
|
17
|
-
private let closure: (
|
|
17
|
+
private let closure: () -> Void
|
|
18
18
|
|
|
19
|
-
public init(_ closure: @escaping (
|
|
19
|
+
public init(_ closure: @escaping () -> Void) {
|
|
20
20
|
self.closure = closure
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
@inline(__always)
|
|
24
|
-
public func call(
|
|
25
|
-
self.closure(
|
|
24
|
+
public func call() -> Void {
|
|
25
|
+
self.closure()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -35,12 +35,12 @@ public final class Func_void_PermissionStatus {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Casts an unsafe pointer to a `
|
|
39
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
40
40
|
* This removes one strong reference from the object!
|
|
41
41
|
*/
|
|
42
42
|
@inline(__always)
|
|
43
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) ->
|
|
44
|
-
return Unmanaged<
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
44
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_bool {
|
|
15
|
+
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Bool) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: Bool) -> Void {
|
|
25
|
+
self.closure(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
44
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__shared_ptr_Promise_bool__.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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: Promise<Bool>) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__shared_ptr_Promise_bool__ {
|
|
15
|
+
public typealias bridge = margelo.nitro.pushsignal.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Promise<Bool>) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Promise<Bool>) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__shared_ptr_Promise_bool__) -> Void {
|
|
25
|
+
self.closure({ () -> Promise<Bool> in
|
|
26
|
+
let __promise = Promise<Bool>()
|
|
27
|
+
let __resolver = { (__result: Bool) in
|
|
28
|
+
__promise.resolve(withResult: __result)
|
|
29
|
+
}
|
|
30
|
+
let __rejecter = { (__error: Error) in
|
|
31
|
+
__promise.reject(withError: __error)
|
|
32
|
+
}
|
|
33
|
+
let __resolverCpp = { () -> bridge.Func_void_bool in
|
|
34
|
+
let __closureWrapper = Func_void_bool(__resolver)
|
|
35
|
+
return bridge.create_Func_void_bool(__closureWrapper.toUnsafe())
|
|
36
|
+
}()
|
|
37
|
+
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
38
|
+
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
39
|
+
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
40
|
+
}()
|
|
41
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(value)
|
|
42
|
+
__promiseHolder.addOnResolvedListenerCopy(__resolverCpp)
|
|
43
|
+
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
44
|
+
return __promise
|
|
45
|
+
}())
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
50
|
+
* This acquires one additional strong reference on the object!
|
|
51
|
+
*/
|
|
52
|
+
@inline(__always)
|
|
53
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
54
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Casts an unsafe pointer to a `Func_void_std__shared_ptr_Promise_bool__`.
|
|
59
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_Promise_bool__>`.
|
|
60
|
+
* This removes one strong reference from the object!
|
|
61
|
+
*/
|
|
62
|
+
@inline(__always)
|
|
63
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_Promise_bool__ {
|
|
64
|
+
return Unmanaged<Func_void_std__shared_ptr_Promise_bool__>.fromOpaque(pointer).takeRetainedValue()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -13,11 +13,9 @@ public protocol HybridPushSignalSpec_protocol: HybridObject {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Methods
|
|
16
|
-
func initialize(config: AndroidFirebaseConfig) throws -> Void
|
|
17
|
-
func getPermissionStatus() throws -> Promise<PermissionStatus>
|
|
18
|
-
func requestPermission() throws -> Promise<PermissionStatus>
|
|
16
|
+
func initialize(config: AndroidFirebaseConfig) throws -> Promise<Void>
|
|
19
17
|
func getCredentials() throws -> Promise<PushCredentials>
|
|
20
|
-
func setOnMessage(callback: @escaping (_ message: PushMessage) ->
|
|
18
|
+
func setOnMessage(callback: @escaping (_ message: PushMessage) -> Promise<Promise<Bool>>) throws -> Void
|
|
21
19
|
func setOnNotificationPress(callback: @escaping (_ message: PushMessage) -> Void) throws -> Void
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -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)
|
|
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)
|
|
145
134
|
__result
|
|
146
|
-
.then({ __result in __promiseHolder.resolve(
|
|
135
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
147
136
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
148
137
|
return __promise
|
|
149
138
|
}()
|
|
150
|
-
return bridge.
|
|
139
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
151
140
|
} catch (let __error) {
|
|
152
141
|
let __exceptionPtr = __error.toCpp()
|
|
153
|
-
return bridge.
|
|
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)
|
|
164
|
-
__result
|
|
165
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
166
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
167
|
-
return __promise
|
|
168
|
-
}()
|
|
169
|
-
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__resultCpp)
|
|
170
|
-
} catch (let __error) {
|
|
171
|
-
let __exceptionPtr = __error.toCpp()
|
|
172
|
-
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__exceptionPtr)
|
|
142
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
173
143
|
}
|
|
174
144
|
}
|
|
175
145
|
|
|
@@ -193,12 +163,33 @@ open class HybridPushSignalSpec_cxx {
|
|
|
193
163
|
}
|
|
194
164
|
|
|
195
165
|
@inline(__always)
|
|
196
|
-
public final func setOnMessage(callback: bridge.
|
|
166
|
+
public final func setOnMessage(callback: bridge.Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage) -> bridge.Result_void_ {
|
|
197
167
|
do {
|
|
198
|
-
try self.__implementation.setOnMessage(callback: { () -> (PushMessage) ->
|
|
199
|
-
let __wrappedFunction = bridge.
|
|
200
|
-
return { (__message: PushMessage) ->
|
|
201
|
-
__wrappedFunction.call(__message)
|
|
168
|
+
try self.__implementation.setOnMessage(callback: { () -> (PushMessage) -> Promise<Promise<Bool>> in
|
|
169
|
+
let __wrappedFunction = bridge.wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage(callback)
|
|
170
|
+
return { (__message: PushMessage) -> Promise<Promise<Bool>> in
|
|
171
|
+
let __result = __wrappedFunction.call(__message)
|
|
172
|
+
return { () -> Promise<Promise<Bool>> in
|
|
173
|
+
let __promise = Promise<Promise<Bool>>()
|
|
174
|
+
let __resolver = { (__result: Promise<Bool>) in
|
|
175
|
+
__promise.resolve(withResult: __result)
|
|
176
|
+
}
|
|
177
|
+
let __rejecter = { (__error: Error) in
|
|
178
|
+
__promise.reject(withError: __error)
|
|
179
|
+
}
|
|
180
|
+
let __resolverCpp = { () -> bridge.Func_void_std__shared_ptr_Promise_bool__ in
|
|
181
|
+
let __closureWrapper = Func_void_std__shared_ptr_Promise_bool__(__resolver)
|
|
182
|
+
return bridge.create_Func_void_std__shared_ptr_Promise_bool__(__closureWrapper.toUnsafe())
|
|
183
|
+
}()
|
|
184
|
+
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
185
|
+
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
186
|
+
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
187
|
+
}()
|
|
188
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_bool____(__result)
|
|
189
|
+
__promiseHolder.addOnResolvedListener(__resolverCpp)
|
|
190
|
+
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
191
|
+
return __promise
|
|
192
|
+
}()
|
|
202
193
|
}
|
|
203
194
|
}())
|
|
204
195
|
return bridge.create_Result_void_()
|
|
@@ -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,11 +57,9 @@ 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
|
-
virtual void setOnMessage(const std::function<
|
|
62
|
+
virtual void setOnMessage(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& callback) = 0;
|
|
68
63
|
virtual void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) = 0;
|
|
69
64
|
|
|
70
65
|
protected:
|
|
@@ -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.2",
|
|
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 {
|
|
@@ -17,21 +17,23 @@ export interface PushMessage {
|
|
|
17
17
|
data: Record<string, string>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export type OnMessageListener = (
|
|
21
|
+
message: PushMessage
|
|
22
|
+
) => boolean | void | Promise<boolean | void>;
|
|
23
|
+
|
|
20
24
|
export interface AndroidFirebaseConfig {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
project_id?: string;
|
|
26
|
+
mobilesdk_app_id?: string;
|
|
27
|
+
current_key?: string;
|
|
28
|
+
project_number?: string;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export interface PushSignal extends HybridObject<{
|
|
28
32
|
ios: 'swift';
|
|
29
33
|
android: 'kotlin';
|
|
30
34
|
}> {
|
|
31
|
-
initialize(config: AndroidFirebaseConfig): void
|
|
32
|
-
getPermissionStatus(): Promise<PermissionStatus>;
|
|
33
|
-
requestPermission(): Promise<PermissionStatus>;
|
|
35
|
+
initialize(config: AndroidFirebaseConfig): Promise<void>;
|
|
34
36
|
getCredentials(): Promise<PushCredentials>;
|
|
35
|
-
setOnMessage(callback: (message: PushMessage) =>
|
|
37
|
+
setOnMessage(callback: (message: PushMessage) => Promise<boolean>): void;
|
|
36
38
|
setOnNotificationPress(callback: (message: PushMessage) => void): void;
|
|
37
39
|
}
|