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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
import NitroModules
|
|
2
3
|
import ObjectiveC
|
|
3
4
|
import UIKit
|
|
4
5
|
import UserNotifications
|
|
@@ -21,7 +22,7 @@ final class PushSignalCenter: NSObject, UNUserNotificationCenterDelegate {
|
|
|
21
22
|
private var pendingLaunchOptions: [AnyHashable: Any]?
|
|
22
23
|
private var didCaptureLaunchNotification = false
|
|
23
24
|
|
|
24
|
-
var onMessage: ((PushMessage) ->
|
|
25
|
+
var onMessage: ((PushMessage) -> Promise<Promise<Bool>>)?
|
|
25
26
|
var onNotificationPress: ((PushMessage) -> Void)? {
|
|
26
27
|
didSet {
|
|
27
28
|
flushPendingPress()
|
|
@@ -46,28 +47,6 @@ final class PushSignalCenter: NSObject, UNUserNotificationCenterDelegate {
|
|
|
46
47
|
captureLaunchNotificationIfNeeded()
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
func permissionStatus() async -> PermissionStatus {
|
|
50
|
-
await withCheckedContinuation { continuation in
|
|
51
|
-
UNUserNotificationCenter.current().getNotificationSettings { settings in
|
|
52
|
-
continuation.resume(returning: Self.map(settings.authorizationStatus))
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
func requestPermission() async -> PermissionStatus {
|
|
58
|
-
do {
|
|
59
|
-
let granted = try await UNUserNotificationCenter.current()
|
|
60
|
-
.requestAuthorization(options: [.alert, .badge, .sound])
|
|
61
|
-
if granted {
|
|
62
|
-
return await permissionStatus()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return await permissionStatus()
|
|
66
|
-
} catch {
|
|
67
|
-
return .denied
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
50
|
func fetchCredentials() async throws -> PushCredentials {
|
|
72
51
|
await MainActor.run {
|
|
73
52
|
self.installOnMain()
|
|
@@ -96,8 +75,11 @@ final class PushSignalCenter: NSObject, UNUserNotificationCenterDelegate {
|
|
|
96
75
|
willPresent notification: UNNotification,
|
|
97
76
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
|
|
98
77
|
) {
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
let message = Self.message(from: notification)
|
|
79
|
+
Task {
|
|
80
|
+
let shouldShow = await self.shouldShowForegroundBanner(for: message)
|
|
81
|
+
completionHandler(shouldShow ? Self.foregroundPresentationOptions : [])
|
|
82
|
+
}
|
|
101
83
|
}
|
|
102
84
|
|
|
103
85
|
func userNotificationCenter(
|
|
@@ -174,12 +156,38 @@ final class PushSignalCenter: NSObject, UNUserNotificationCenterDelegate {
|
|
|
174
156
|
waiters.forEach { $0(result) }
|
|
175
157
|
}
|
|
176
158
|
|
|
177
|
-
private func
|
|
178
|
-
|
|
179
|
-
|
|
159
|
+
private func shouldShowForegroundBanner(for message: PushMessage) async -> Bool {
|
|
160
|
+
guard let callback = onMessage else {
|
|
161
|
+
return false
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return await withTaskGroup(of: Bool.self) { group in
|
|
165
|
+
group.addTask {
|
|
166
|
+
do {
|
|
167
|
+
let inner = try await callback(message).await()
|
|
168
|
+
return try await inner.await()
|
|
169
|
+
} catch {
|
|
170
|
+
return false
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
group.addTask {
|
|
174
|
+
try? await Task.sleep(nanoseconds: 2_000_000_000)
|
|
175
|
+
return false
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
let first = await group.next() ?? false
|
|
179
|
+
group.cancelAll()
|
|
180
|
+
return first
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
private static var foregroundPresentationOptions: UNNotificationPresentationOptions {
|
|
185
|
+
if #available(iOS 14.0, *) {
|
|
186
|
+
return [.banner, .list, .sound, .badge]
|
|
187
|
+
}
|
|
188
|
+
return [.alert, .sound, .badge]
|
|
189
|
+
}
|
|
190
|
+
|
|
183
191
|
private func emitPress(_ message: PushMessage) {
|
|
184
192
|
DispatchQueue.main.async {
|
|
185
193
|
if let onNotificationPress = self.onNotificationPress {
|
|
@@ -267,19 +275,6 @@ final class PushSignalCenter: NSObject, UNUserNotificationCenterDelegate {
|
|
|
267
275
|
}
|
|
268
276
|
}
|
|
269
277
|
|
|
270
|
-
private static func map(_ status: UNAuthorizationStatus) -> PermissionStatus {
|
|
271
|
-
switch status {
|
|
272
|
-
case .authorized, .provisional, .ephemeral:
|
|
273
|
-
return .authorized
|
|
274
|
-
case .denied:
|
|
275
|
-
return .denied
|
|
276
|
-
case .notDetermined:
|
|
277
|
-
return .notdetermined
|
|
278
|
-
@unknown default:
|
|
279
|
-
return .denied
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
278
|
private static func message(from notification: UNNotification) -> PushMessage {
|
|
284
279
|
let content = notification.request.content
|
|
285
280
|
return message(
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export { getCredentials,
|
|
3
|
+
export { getCredentials, initialize, onMessage, onNotificationPress } from './pushSignal';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getCredentials","
|
|
1
|
+
{"version":3,"names":["getCredentials","initialize","onMessage","onNotificationPress"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAQA,SACEA,cAAc,EACdC,UAAU,EACVC,SAAS,EACTC,mBAAmB,QACd,cAAc","ignoreList":[]}
|
package/lib/module/pushSignal.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export function initialize(_config = {}) {}
|
|
4
|
-
export async function getPermissionStatus() {
|
|
5
|
-
return 'denied';
|
|
6
|
-
}
|
|
7
|
-
export async function requestPermission() {
|
|
8
|
-
return 'denied';
|
|
9
|
-
}
|
|
3
|
+
export async function initialize(_config = {}) {}
|
|
10
4
|
export async function getCredentials() {
|
|
11
5
|
throw new Error('Push credentials are not supported on web');
|
|
12
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initialize","_config","
|
|
1
|
+
{"version":3,"names":["initialize","_config","getCredentials","Error","onMessage","_listener","onNotificationPress"],"sourceRoot":"../../src","sources":["pushSignal.tsx"],"mappings":";;AAOA,OAAO,eAAeA,UAAUA,CAC9BC,OAA8B,GAAG,CAAC,CAAC,EACpB,CAAC;AAElB,OAAO,eAAeC,cAAcA,CAAA,EAA6B;EAC/D,MAAM,IAAIC,KAAK,CAAC,2CAA2C,CAAC;AAC9D;AAEA,OAAO,SAASC,SAASA,CAACC,SAA4B,EAAc;EAClE,OAAO,MAAM,CAAC,CAAC;AACjB;AAEA,OAAO,SAASC,mBAAmBA,CACjCD,SAAyC,EAC7B;EACZ,OAAO,MAAM,CAAC,CAAC;AACjB","ignoreList":[]}
|
|
@@ -10,21 +10,22 @@ function bindNativeCallbacks() {
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
nativeCallbacksBound = true;
|
|
13
|
-
PushSignalHybridObject.setOnMessage(message => {
|
|
14
|
-
messageListeners.
|
|
13
|
+
PushSignalHybridObject.setOnMessage(async message => {
|
|
14
|
+
const results = await Promise.all([...messageListeners].map(async listener => {
|
|
15
|
+
try {
|
|
16
|
+
return await listener(message);
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
return results.some(result => result === true);
|
|
15
22
|
});
|
|
16
23
|
PushSignalHybridObject.setOnNotificationPress(message => {
|
|
17
24
|
pressListeners.forEach(listener => listener(message));
|
|
18
25
|
});
|
|
19
26
|
}
|
|
20
27
|
export function initialize(config = {}) {
|
|
21
|
-
PushSignalHybridObject.initialize(config);
|
|
22
|
-
}
|
|
23
|
-
export function getPermissionStatus() {
|
|
24
|
-
return PushSignalHybridObject.getPermissionStatus();
|
|
25
|
-
}
|
|
26
|
-
export function requestPermission() {
|
|
27
|
-
return PushSignalHybridObject.requestPermission();
|
|
28
|
+
return PushSignalHybridObject.initialize(config);
|
|
28
29
|
}
|
|
29
30
|
export function getCredentials() {
|
|
30
31
|
return PushSignalHybridObject.getCredentials();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModules","PushSignalHybridObject","createHybridObject","messageListeners","Set","pressListeners","nativeCallbacksBound","bindNativeCallbacks","setOnMessage","message","
|
|
1
|
+
{"version":3,"names":["NitroModules","PushSignalHybridObject","createHybridObject","messageListeners","Set","pressListeners","nativeCallbacksBound","bindNativeCallbacks","setOnMessage","message","results","Promise","all","map","listener","some","result","setOnNotificationPress","forEach","initialize","config","getCredentials","onMessage","add","delete","onNotificationPress"],"sourceRoot":"../../src","sources":["pushSignal.native.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AASzD,MAAMC,sBAAsB,GAC1BD,YAAY,CAACE,kBAAkB,CAAa,YAAY,CAAC;AAE3D,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAoB,CAAC;AACrD,MAAMC,cAAc,GAAG,IAAID,GAAG,CAAiC,CAAC;AAChE,IAAIE,oBAAoB,GAAG,KAAK;AAEhC,SAASC,mBAAmBA,CAAA,EAAG;EAC7B,IAAID,oBAAoB,EAAE;IACxB;EACF;EAEAA,oBAAoB,GAAG,IAAI;EAE3BL,sBAAsB,CAACO,YAAY,CAAC,MAAOC,OAAO,IAAK;IACrD,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/B,CAAC,GAAGT,gBAAgB,CAAC,CAACU,GAAG,CAAC,MAAOC,QAAQ,IAAK;MAC5C,IAAI;QACF,OAAO,MAAMA,QAAQ,CAACL,OAAO,CAAC;MAChC,CAAC,CAAC,MAAM;QACN,OAAO,KAAK;MACd;IACF,CAAC,CACH,CAAC;IAED,OAAOC,OAAO,CAACK,IAAI,CAAEC,MAAM,IAAKA,MAAM,KAAK,IAAI,CAAC;EAClD,CAAC,CAAC;EAEFf,sBAAsB,CAACgB,sBAAsB,CAAER,OAAO,IAAK;IACzDJ,cAAc,CAACa,OAAO,CAAEJ,QAAQ,IAAKA,QAAQ,CAACL,OAAO,CAAC,CAAC;EACzD,CAAC,CAAC;AACJ;AAEA,OAAO,SAASU,UAAUA,CAACC,MAA6B,GAAG,CAAC,CAAC,EAAiB;EAC5E,OAAOnB,sBAAsB,CAACkB,UAAU,CAACC,MAAM,CAAC;AAClD;AAEA,OAAO,SAASC,cAAcA,CAAA,EAA6B;EACzD,OAAOpB,sBAAsB,CAACoB,cAAc,CAAC,CAAC;AAChD;AAEA,OAAO,SAASC,SAASA,CAACR,QAA2B,EAAc;EACjEP,mBAAmB,CAAC,CAAC;EACrBJ,gBAAgB,CAACoB,GAAG,CAACT,QAAQ,CAAC;EAC9B,OAAO,MAAM;IACXX,gBAAgB,CAACqB,MAAM,CAACV,QAAQ,CAAC;EACnC,CAAC;AACH;AAEA,OAAO,SAASW,mBAAmBA,CACjCX,QAAwC,EAC5B;EACZP,mBAAmB,CAAC,CAAC;EACrBF,cAAc,CAACkB,GAAG,CAACT,QAAQ,CAAC;EAC5B,OAAO,MAAM;IACXT,cAAc,CAACmB,MAAM,CAACV,QAAQ,CAAC;EACjC,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
|
|
3
|
-
export type PushPlatform = 'ios' | '
|
|
2
|
+
/** JS/C++ name cannot be `android`: NDK defines `-DANDROID` and breaks the generated enum. */
|
|
3
|
+
export type PushPlatform = 'ios' | 'android_os';
|
|
4
4
|
export type PushEnvironment = 'sandbox' | 'production';
|
|
5
5
|
export interface PushCredentials {
|
|
6
6
|
platform: PushPlatform;
|
|
@@ -13,21 +13,20 @@ export interface PushMessage {
|
|
|
13
13
|
body?: string;
|
|
14
14
|
data: Record<string, string>;
|
|
15
15
|
}
|
|
16
|
+
export type OnMessageListener = (message: PushMessage) => boolean | void | Promise<boolean | void>;
|
|
16
17
|
export interface AndroidFirebaseConfig {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
project_id?: string;
|
|
19
|
+
mobilesdk_app_id?: string;
|
|
20
|
+
current_key?: string;
|
|
21
|
+
project_number?: string;
|
|
21
22
|
}
|
|
22
23
|
export interface PushSignal extends HybridObject<{
|
|
23
24
|
ios: 'swift';
|
|
24
25
|
android: 'kotlin';
|
|
25
26
|
}> {
|
|
26
|
-
initialize(config: AndroidFirebaseConfig): void
|
|
27
|
-
getPermissionStatus(): Promise<PermissionStatus>;
|
|
28
|
-
requestPermission(): Promise<PermissionStatus>;
|
|
27
|
+
initialize(config: AndroidFirebaseConfig): Promise<void>;
|
|
29
28
|
getCredentials(): Promise<PushCredentials>;
|
|
30
|
-
setOnMessage(callback: (message: PushMessage) =>
|
|
29
|
+
setOnMessage(callback: (message: PushMessage) => Promise<boolean>): void;
|
|
31
30
|
setOnNotificationPress(callback: (message: PushMessage) => void): void;
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=PushSignal.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushSignal.nitro.d.ts","sourceRoot":"","sources":["../../../src/PushSignal.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,
|
|
1
|
+
{"version":3,"file":"PushSignal.nitro.d.ts","sourceRoot":"","sources":["../../../src/PushSignal.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,8FAA8F;AAC9F,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,YAAY,CAAC;AAChD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,YAAY,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,OAAO,EAAE,WAAW,KACjB,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE9C,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY,CAAC;IAC/C,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,UAAU,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C,YAAY,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACzE,sBAAsB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;CACxE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { AndroidFirebaseConfig,
|
|
2
|
-
export { getCredentials,
|
|
1
|
+
export type { AndroidFirebaseConfig, OnMessageListener, PushCredentials, PushEnvironment, PushMessage, PushPlatform, } from './PushSignal.nitro.js';
|
|
2
|
+
export { getCredentials, initialize, onMessage, onNotificationPress, } from './pushSignal';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,uBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { AndroidFirebaseConfig,
|
|
2
|
-
export declare function initialize(_config?: AndroidFirebaseConfig): void
|
|
3
|
-
export declare function getPermissionStatus(): Promise<PermissionStatus>;
|
|
4
|
-
export declare function requestPermission(): Promise<PermissionStatus>;
|
|
1
|
+
import type { AndroidFirebaseConfig, OnMessageListener, PushCredentials, PushMessage } from './PushSignal.nitro.js';
|
|
2
|
+
export declare function initialize(_config?: AndroidFirebaseConfig): Promise<void>;
|
|
5
3
|
export declare function getCredentials(): Promise<PushCredentials>;
|
|
6
|
-
export declare function onMessage(_listener:
|
|
4
|
+
export declare function onMessage(_listener: OnMessageListener): () => void;
|
|
7
5
|
export declare function onNotificationPress(_listener: (message: PushMessage) => void): () => void;
|
|
8
6
|
//# sourceMappingURL=pushSignal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushSignal.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"pushSignal.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACZ,MAAM,uBAAoB,CAAC;AAE5B,wBAAsB,UAAU,CAC9B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAAG;AAEnB,wBAAsB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAE/D;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAElE;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACxC,MAAM,IAAI,CAEZ"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { AndroidFirebaseConfig,
|
|
2
|
-
export declare function initialize(config?: AndroidFirebaseConfig): void
|
|
3
|
-
export declare function getPermissionStatus(): Promise<PermissionStatus>;
|
|
4
|
-
export declare function requestPermission(): Promise<PermissionStatus>;
|
|
1
|
+
import type { AndroidFirebaseConfig, OnMessageListener, PushCredentials, PushMessage } from './PushSignal.nitro.js';
|
|
2
|
+
export declare function initialize(config?: AndroidFirebaseConfig): Promise<void>;
|
|
5
3
|
export declare function getCredentials(): Promise<PushCredentials>;
|
|
6
|
-
export declare function onMessage(listener:
|
|
4
|
+
export declare function onMessage(listener: OnMessageListener): () => void;
|
|
7
5
|
export declare function onNotificationPress(listener: (message: PushMessage) => void): () => void;
|
|
8
6
|
//# sourceMappingURL=pushSignal.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushSignal.native.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"pushSignal.native.d.ts","sourceRoot":"","sources":["../../../src/pushSignal.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,WAAW,EAEZ,MAAM,uBAAoB,CAAC;AAmC5B,wBAAgB,UAAU,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAEzD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAMjE;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GACvC,MAAM,IAAI,CAMZ"}
|
|
@@ -32,19 +32,19 @@ namespace margelo::nitro::pushsignal {
|
|
|
32
32
|
[[nodiscard]]
|
|
33
33
|
AndroidFirebaseConfig toCpp() const {
|
|
34
34
|
static const auto clazz = javaClassStatic();
|
|
35
|
-
static const auto
|
|
36
|
-
jni::local_ref<jni::JString>
|
|
37
|
-
static const auto
|
|
38
|
-
jni::local_ref<jni::JString>
|
|
39
|
-
static const auto
|
|
40
|
-
jni::local_ref<jni::JString>
|
|
41
|
-
static const auto
|
|
42
|
-
jni::local_ref<jni::JString>
|
|
35
|
+
static const auto fieldProject_id = clazz->getField<jni::JString>("project_id");
|
|
36
|
+
jni::local_ref<jni::JString> project_id = this->getFieldValue(fieldProject_id);
|
|
37
|
+
static const auto fieldMobilesdk_app_id = clazz->getField<jni::JString>("mobilesdk_app_id");
|
|
38
|
+
jni::local_ref<jni::JString> mobilesdk_app_id = this->getFieldValue(fieldMobilesdk_app_id);
|
|
39
|
+
static const auto fieldCurrent_key = clazz->getField<jni::JString>("current_key");
|
|
40
|
+
jni::local_ref<jni::JString> current_key = this->getFieldValue(fieldCurrent_key);
|
|
41
|
+
static const auto fieldProject_number = clazz->getField<jni::JString>("project_number");
|
|
42
|
+
jni::local_ref<jni::JString> project_number = this->getFieldValue(fieldProject_number);
|
|
43
43
|
return AndroidFirebaseConfig(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
project_id != nullptr ? std::make_optional(project_id->toStdString()) : std::nullopt,
|
|
45
|
+
mobilesdk_app_id != nullptr ? std::make_optional(mobilesdk_app_id->toStdString()) : std::nullopt,
|
|
46
|
+
current_key != nullptr ? std::make_optional(current_key->toStdString()) : std::nullopt,
|
|
47
|
+
project_number != nullptr ? std::make_optional(project_number->toStdString()) : std::nullopt
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -59,10 +59,10 @@ namespace margelo::nitro::pushsignal {
|
|
|
59
59
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
60
60
|
return create(
|
|
61
61
|
clazz,
|
|
62
|
-
value.
|
|
63
|
-
value.
|
|
64
|
-
value.
|
|
65
|
-
value.
|
|
62
|
+
value.project_id.has_value() ? jni::make_jstring(value.project_id.value()) : nullptr,
|
|
63
|
+
value.mobilesdk_app_id.has_value() ? jni::make_jstring(value.mobilesdk_app_id.value()) : nullptr,
|
|
64
|
+
value.current_key.has_value() ? jni::make_jstring(value.current_key.value()) : nullptr,
|
|
65
|
+
value.project_number.has_value() ? jni::make_jstring(value.project_number.value()) : nullptr
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/Promise.hpp>
|
|
14
|
+
#include "PushMessage.hpp"
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <NitroModules/JNICallable.hpp>
|
|
17
|
+
#include <NitroModules/JPromise.hpp>
|
|
18
|
+
#include "JPushMessage.hpp"
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <unordered_map>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::pushsignal {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Represents the Java/Kotlin callback `(message: PushMessage) -> Promise<Promise<Boolean>>`.
|
|
29
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
30
|
+
*/
|
|
31
|
+
struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage: public jni::JavaClass<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage> {
|
|
32
|
+
public:
|
|
33
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage;";
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
/**
|
|
37
|
+
* Invokes the function this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage` instance holds through JNI.
|
|
38
|
+
*/
|
|
39
|
+
std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> invoke(const PushMessage& message) const {
|
|
40
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JPushMessage> /* message */)>("invoke");
|
|
41
|
+
auto __result = method(self(), JPushMessage::fromCpp(message));
|
|
42
|
+
return [&]() {
|
|
43
|
+
auto __promise = Promise<std::shared_ptr<Promise<bool>>>::create();
|
|
44
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
45
|
+
auto __result = jni::static_ref_cast<JPromise::javaobject>(__boxedResult);
|
|
46
|
+
__promise->resolve([&]() {
|
|
47
|
+
auto __promise = Promise<bool>::create();
|
|
48
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
49
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
50
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
51
|
+
});
|
|
52
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
53
|
+
jni::JniException __jniError(__throwable);
|
|
54
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
55
|
+
});
|
|
56
|
+
return __promise;
|
|
57
|
+
}());
|
|
58
|
+
});
|
|
59
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
60
|
+
jni::JniException __jniError(__throwable);
|
|
61
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
62
|
+
});
|
|
63
|
+
return __promise;
|
|
64
|
+
}();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* An implementation of Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage that is backed by a C++ implementation (using `std::function<...>`)
|
|
70
|
+
*/
|
|
71
|
+
class JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx final: public jni::HybridClass<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage> {
|
|
72
|
+
public:
|
|
73
|
+
static jni::local_ref<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage::javaobject> fromCpp(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& func) {
|
|
74
|
+
return JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx::newObjectCxxArgs(func);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public:
|
|
78
|
+
/**
|
|
79
|
+
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx` instance holds.
|
|
80
|
+
*/
|
|
81
|
+
jni::local_ref<JPromise::javaobject> invoke_cxx(jni::alias_ref<JPushMessage> message) {
|
|
82
|
+
std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>> __result = _func(message->toCpp());
|
|
83
|
+
return [&]() {
|
|
84
|
+
jni::local_ref<JPromise::javaobject> __localPromise = JPromise::create();
|
|
85
|
+
jni::global_ref<JPromise::javaobject> __promise = jni::make_global(__localPromise);
|
|
86
|
+
__result->addOnResolvedListener([=](const std::shared_ptr<Promise<bool>>& __result) {
|
|
87
|
+
__promise->cthis()->resolve([&]() {
|
|
88
|
+
jni::local_ref<JPromise::javaobject> __localPromise = JPromise::create();
|
|
89
|
+
jni::global_ref<JPromise::javaobject> __promise = jni::make_global(__localPromise);
|
|
90
|
+
__result->addOnResolvedListener([=](const bool& __result) {
|
|
91
|
+
__promise->cthis()->resolve(jni::JBoolean::valueOf(__result));
|
|
92
|
+
});
|
|
93
|
+
__result->addOnRejectedListener([=](const std::exception_ptr& __error) {
|
|
94
|
+
auto __jniError = jni::getJavaExceptionForCppException(__error);
|
|
95
|
+
__promise->cthis()->reject(__jniError);
|
|
96
|
+
});
|
|
97
|
+
return __localPromise;
|
|
98
|
+
}());
|
|
99
|
+
});
|
|
100
|
+
__result->addOnRejectedListener([=](const std::exception_ptr& __error) {
|
|
101
|
+
auto __jniError = jni::getJavaExceptionForCppException(__error);
|
|
102
|
+
__promise->cthis()->reject(__jniError);
|
|
103
|
+
});
|
|
104
|
+
return __localPromise;
|
|
105
|
+
}();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public:
|
|
109
|
+
[[nodiscard]]
|
|
110
|
+
inline const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& getFunction() const {
|
|
111
|
+
return _func;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public:
|
|
115
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx;";
|
|
116
|
+
static void registerNatives() {
|
|
117
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx::invoke_cxx)});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private:
|
|
121
|
+
explicit JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& func): _func(func) { }
|
|
122
|
+
|
|
123
|
+
private:
|
|
124
|
+
friend HybridBase;
|
|
125
|
+
std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)> _func;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
} // namespace margelo::nitro::pushsignal
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridPushSignalSpec.hpp"
|
|
9
9
|
|
|
10
|
-
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
11
|
-
namespace margelo::nitro::pushsignal { enum class PermissionStatus; }
|
|
12
10
|
// Forward declaration of `PushCredentials` to properly resolve imports.
|
|
13
11
|
namespace margelo::nitro::pushsignal { struct PushCredentials; }
|
|
14
12
|
// Forward declaration of `PushPlatform` to properly resolve imports.
|
|
@@ -20,10 +18,9 @@ namespace margelo::nitro::pushsignal { struct AndroidFirebaseConfig; }
|
|
|
20
18
|
// Forward declaration of `PushMessage` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
22
20
|
|
|
23
|
-
#include "PermissionStatus.hpp"
|
|
24
21
|
#include <NitroModules/Promise.hpp>
|
|
25
22
|
#include <NitroModules/JPromise.hpp>
|
|
26
|
-
#include
|
|
23
|
+
#include <NitroModules/JUnit.hpp>
|
|
27
24
|
#include "PushCredentials.hpp"
|
|
28
25
|
#include "JPushCredentials.hpp"
|
|
29
26
|
#include "PushPlatform.hpp"
|
|
@@ -36,10 +33,11 @@ namespace margelo::nitro::pushsignal { struct PushMessage; }
|
|
|
36
33
|
#include "JAndroidFirebaseConfig.hpp"
|
|
37
34
|
#include "PushMessage.hpp"
|
|
38
35
|
#include <functional>
|
|
39
|
-
#include "
|
|
36
|
+
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage.hpp"
|
|
40
37
|
#include <NitroModules/JNICallable.hpp>
|
|
41
38
|
#include "JPushMessage.hpp"
|
|
42
39
|
#include <unordered_map>
|
|
40
|
+
#include "JFunc_void_PushMessage.hpp"
|
|
43
41
|
|
|
44
42
|
namespace margelo::nitro::pushsignal {
|
|
45
43
|
|
|
@@ -74,34 +72,13 @@ namespace margelo::nitro::pushsignal {
|
|
|
74
72
|
|
|
75
73
|
|
|
76
74
|
// Methods
|
|
77
|
-
void JHybridPushSignalSpec::initialize(const AndroidFirebaseConfig& config) {
|
|
78
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<
|
|
79
|
-
method(_javaPart, JAndroidFirebaseConfig::fromCpp(config));
|
|
80
|
-
}
|
|
81
|
-
std::shared_ptr<Promise<PermissionStatus>> JHybridPushSignalSpec::getPermissionStatus() {
|
|
82
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getPermissionStatus");
|
|
83
|
-
auto __result = method(_javaPart);
|
|
75
|
+
std::shared_ptr<Promise<void>> JHybridPushSignalSpec::initialize(const AndroidFirebaseConfig& config) {
|
|
76
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JAndroidFirebaseConfig> /* config */)>("initialize");
|
|
77
|
+
auto __result = method(_javaPart, JAndroidFirebaseConfig::fromCpp(config));
|
|
84
78
|
return [&]() {
|
|
85
|
-
auto __promise = Promise<
|
|
86
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>&
|
|
87
|
-
|
|
88
|
-
__promise->resolve(__result->toCpp());
|
|
89
|
-
});
|
|
90
|
-
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
91
|
-
jni::JniException __jniError(__throwable);
|
|
92
|
-
__promise->reject(std::make_exception_ptr(__jniError));
|
|
93
|
-
});
|
|
94
|
-
return __promise;
|
|
95
|
-
}();
|
|
96
|
-
}
|
|
97
|
-
std::shared_ptr<Promise<PermissionStatus>> JHybridPushSignalSpec::requestPermission() {
|
|
98
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestPermission");
|
|
99
|
-
auto __result = method(_javaPart);
|
|
100
|
-
return [&]() {
|
|
101
|
-
auto __promise = Promise<PermissionStatus>::create();
|
|
102
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
103
|
-
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
104
|
-
__promise->resolve(__result->toCpp());
|
|
79
|
+
auto __promise = Promise<void>::create();
|
|
80
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
81
|
+
__promise->resolve();
|
|
105
82
|
});
|
|
106
83
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
107
84
|
jni::JniException __jniError(__throwable);
|
|
@@ -126,9 +103,9 @@ namespace margelo::nitro::pushsignal {
|
|
|
126
103
|
return __promise;
|
|
127
104
|
}();
|
|
128
105
|
}
|
|
129
|
-
void JHybridPushSignalSpec::setOnMessage(const std::function<
|
|
130
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<
|
|
131
|
-
method(_javaPart,
|
|
106
|
+
void JHybridPushSignalSpec::setOnMessage(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& callback) {
|
|
107
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage::javaobject> /* callback */)>("setOnMessage_cxx");
|
|
108
|
+
method(_javaPart, JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_bool_____PushMessage_cxx::fromCpp(callback));
|
|
132
109
|
}
|
|
133
110
|
void JHybridPushSignalSpec::setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) {
|
|
134
111
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PushMessage::javaobject> /* callback */)>("setOnNotificationPress_cxx");
|
|
@@ -54,11 +54,9 @@ namespace margelo::nitro::pushsignal {
|
|
|
54
54
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
|
-
void initialize(const AndroidFirebaseConfig& config) override;
|
|
58
|
-
std::shared_ptr<Promise<PermissionStatus>> getPermissionStatus() override;
|
|
59
|
-
std::shared_ptr<Promise<PermissionStatus>> requestPermission() override;
|
|
57
|
+
std::shared_ptr<Promise<void>> initialize(const AndroidFirebaseConfig& config) override;
|
|
60
58
|
std::shared_ptr<Promise<PushCredentials>> getCredentials() override;
|
|
61
|
-
void setOnMessage(const std::function<
|
|
59
|
+
void setOnMessage(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<bool>>>>(const PushMessage& /* message */)>& callback) override;
|
|
62
60
|
void setOnNotificationPress(const std::function<void(const PushMessage& /* message */)>& callback) override;
|
|
63
61
|
|
|
64
62
|
private:
|
|
@@ -45,9 +45,9 @@ namespace margelo::nitro::pushsignal {
|
|
|
45
45
|
case PushPlatform::IOS:
|
|
46
46
|
static const auto fieldIOS = clazz->getStaticField<JPushPlatform>("IOS");
|
|
47
47
|
return clazz->getStaticFieldValue(fieldIOS);
|
|
48
|
-
case PushPlatform::
|
|
49
|
-
static const auto
|
|
50
|
-
return clazz->getStaticFieldValue(
|
|
48
|
+
case PushPlatform::ANDROID_OS:
|
|
49
|
+
static const auto fieldANDROID_OS = clazz->getStaticField<JPushPlatform>("ANDROID_OS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldANDROID_OS);
|
|
51
51
|
default:
|
|
52
52
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
53
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|