react-native-acoustic-connect-beta 18.0.26 → 18.0.27
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/AcousticConnectRN.podspec +4 -1
- package/android/src/main/assets/ConnectBasicConfig.properties +1 -1
- package/android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt +54 -0
- package/ios/HybridAcousticConnectRN.swift +177 -0
- package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts +109 -0
- package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/AcousticConnectRN+autolinking.cmake +1 -0
- package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.cpp +137 -1
- package/nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.hpp +7 -0
- package/nitrogen/generated/android/c++/JPushErrorInfo.hpp +66 -0
- package/nitrogen/generated/android/c++/JPushPermissionResult.hpp +66 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/HybridAcousticConnectRNSpec.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/PushErrorInfo.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/PushPermissionResult.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/acousticconnectrn/Variant_NullType_Boolean.kt +62 -0
- package/nitrogen/generated/ios/AcousticConnectRN-Swift-Cxx-Bridge.cpp +32 -0
- package/nitrogen/generated/ios/AcousticConnectRN-Swift-Cxx-Bridge.hpp +249 -0
- package/nitrogen/generated/ios/AcousticConnectRN-Swift-Cxx-Umbrella.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridAcousticConnectRNSpecSwift.hpp +67 -1
- package/nitrogen/generated/ios/swift/Func_void_PushPermissionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__bool_.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec.swift +7 -0
- package/nitrogen/generated/ios/swift/HybridAcousticConnectRNSpec_cxx.swift +205 -0
- package/nitrogen/generated/ios/swift/PushErrorInfo.swift +65 -0
- package/nitrogen/generated/ios/swift/PushPermissionResult.swift +66 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_Bool.swift +30 -0
- package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.cpp +7 -0
- package/nitrogen/generated/shared/c++/HybridAcousticConnectRNSpec.hpp +15 -1
- package/nitrogen/generated/shared/c++/PushErrorInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/PushPermissionResult.hpp +90 -0
- package/package.json +1 -1
- package/src/specs/react-native-acoustic-connect.nitro.ts +128 -0
|
@@ -28,7 +28,10 @@ iOSVersion = connectConfig["Connect"]["iOSVersion"]
|
|
|
28
28
|
# place to introduce a conditional floor keyed off
|
|
29
29
|
# `ConnectConfig.json -> Connect.PushEnabled` (mirrors the Android conditional
|
|
30
30
|
# on `connect-push-fcm` in `android/build.gradle`).
|
|
31
|
-
|
|
31
|
+
# 2.1.12 floor: `ConnectSDK.shared.push.requestAuthorization()` and
|
|
32
|
+
# `getCurrentAuthorization()` (CA-144303) land in 2.1.12. The push permission
|
|
33
|
+
# bridge methods call them directly, so an older pod would fail to compile.
|
|
34
|
+
sdkFloor = '>= 2.1.12'
|
|
32
35
|
dependencyRequirements = iOSVersion.to_s.empty? ? [sdkFloor] : [sdkFloor, iOSVersion]
|
|
33
36
|
|
|
34
37
|
# Write the merged consumer config to the resource-bundle source path AT POD INSTALL TIME.
|
|
@@ -54,8 +54,13 @@ import com.ibm.eo.EOCore
|
|
|
54
54
|
import com.ibm.eo.model.EOMonitoringLevel
|
|
55
55
|
import com.margelo.nitro.NitroModules.Companion.applicationContext
|
|
56
56
|
import com.margelo.nitro.acousticconnectrn.HybridAcousticConnectRNSpec
|
|
57
|
+
import com.margelo.nitro.acousticconnectrn.PushErrorInfo
|
|
58
|
+
import com.margelo.nitro.acousticconnectrn.PushPermissionResult
|
|
57
59
|
import com.margelo.nitro.acousticconnectrn.Variant_Boolean_String_Double
|
|
60
|
+
import com.margelo.nitro.acousticconnectrn.Variant_NullType_Boolean
|
|
58
61
|
import com.margelo.nitro.acousticconnectrn.Variant_NullType_String
|
|
62
|
+
import com.margelo.nitro.core.ArrayBuffer
|
|
63
|
+
import com.margelo.nitro.core.Promise
|
|
59
64
|
import com.tl.uic.Tealeaf
|
|
60
65
|
import com.tl.uic.model.ScreenviewType
|
|
61
66
|
import com.tl.uic.util.DialogUtil
|
|
@@ -226,6 +231,55 @@ class HybridAcousticConnectRN : HybridAcousticConnectRNSpec(),
|
|
|
226
231
|
return true
|
|
227
232
|
}
|
|
228
233
|
|
|
234
|
+
// MARK: - Push (Android) — STUBS
|
|
235
|
+
//
|
|
236
|
+
// The shared Nitro spec (added by the iOS push story, CA-137697) declares
|
|
237
|
+
// these as abstract members on BOTH platforms, so the Android library must
|
|
238
|
+
// implement them to compile. These are intentional NO-OP placeholders to
|
|
239
|
+
// keep the shared spec landable; the real Android behaviour lands with:
|
|
240
|
+
// - CA-144821: pushGetToken / pushGetTokenAsync (separate session)
|
|
241
|
+
// - CA-144822: pushDidReceiveNotification manual-mode dispatch
|
|
242
|
+
// - CA-144823: permission methods (request / get / authorization)
|
|
243
|
+
// until then they return inert defaults and never throw.
|
|
244
|
+
|
|
245
|
+
override fun pushDidRegisterWithToken(deviceToken: ArrayBuffer): Promise<Boolean> {
|
|
246
|
+
Log.w(TAG, "[bridge] pushDidRegisterWithToken: Android stub (CA-144822/823 pending)")
|
|
247
|
+
return Promise.resolved(false)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
override fun pushDidFailToRegister(error: PushErrorInfo): Promise<Boolean> {
|
|
251
|
+
Log.w(TAG, "[bridge] pushDidFailToRegister: Android stub (CA-144822/823 pending)")
|
|
252
|
+
return Promise.resolved(false)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
override fun pushDidReceiveNotification(userInfo: Map<String, Variant_Boolean_String_Double>): Promise<Boolean> {
|
|
256
|
+
Log.w(TAG, "[bridge] pushDidReceiveNotification: Android stub (CA-144822 pending)")
|
|
257
|
+
return Promise.resolved(false)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
override fun pushDidReceiveResponse(
|
|
261
|
+
actionIdentifier: String,
|
|
262
|
+
userInfo: Map<String, Variant_Boolean_String_Double>
|
|
263
|
+
): Promise<Boolean> {
|
|
264
|
+
Log.w(TAG, "[bridge] pushDidReceiveResponse: Android stub (CA-144822 pending)")
|
|
265
|
+
return Promise.resolved(false)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
override fun pushDidReceiveAuthorization(granted: Variant_NullType_Boolean?, error: PushErrorInfo?): Promise<Boolean> {
|
|
269
|
+
Log.w(TAG, "[bridge] pushDidReceiveAuthorization: Android stub (CA-144823 pending)")
|
|
270
|
+
return Promise.resolved(false)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
override fun pushRequestPermission(): Promise<PushPermissionResult> {
|
|
274
|
+
Log.w(TAG, "[bridge] pushRequestPermission: Android stub (CA-144823 pending)")
|
|
275
|
+
return Promise.resolved(PushPermissionResult(granted = false, error = null))
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
override fun pushGetPermissionState(): Promise<Variant_NullType_Boolean> {
|
|
279
|
+
Log.w(TAG, "[bridge] pushGetPermissionState: Android stub (CA-144823 pending)")
|
|
280
|
+
return Promise.resolved(Variant_NullType_Boolean.create(false))
|
|
281
|
+
}
|
|
282
|
+
|
|
229
283
|
/**
|
|
230
284
|
* Checks whether the `connect-push-fcm` artifact is on the classpath and
|
|
231
285
|
* logs the result. The artifact is gated by `Connect.PushEnabled` in
|
|
@@ -62,8 +62,37 @@ private enum ConnectConfigStore {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// MARK: - Push adapter wrappers
|
|
66
|
+
|
|
67
|
+
/// Bridges a JS-supplied `userInfo` dictionary to the SDK's `ConnectNotification`
|
|
68
|
+
/// protocol (a single `userInfo` requirement).
|
|
69
|
+
private struct HybridAcousticConnectNotification: ConnectNotification {
|
|
70
|
+
let userInfo: [AnyHashable: Any]
|
|
71
|
+
|
|
72
|
+
init(userInfo: [String: Any]) {
|
|
73
|
+
self.userInfo = userInfo.reduce(into: [AnyHashable: Any]()) { $0[$1.key] = $1.value }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// Bridges a JS-supplied response to the SDK's `ConnectNotificationResponse`
|
|
78
|
+
/// protocol (`actionIdentifier` + `userInfo`).
|
|
79
|
+
private struct HybridAcousticConnectNotificationResponse: ConnectNotificationResponse {
|
|
80
|
+
let actionIdentifier: String
|
|
81
|
+
let userInfo: [AnyHashable: Any]
|
|
82
|
+
|
|
83
|
+
init(actionIdentifier: String, userInfo: [String: Any]) {
|
|
84
|
+
self.actionIdentifier = actionIdentifier
|
|
85
|
+
self.userInfo = userInfo.reduce(into: [AnyHashable: Any]()) { $0[$1.key] = $1.value }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
65
89
|
class HybridAcousticConnectRN: HybridAcousticConnectRNSpec {
|
|
66
90
|
|
|
91
|
+
/// Push mode resolved from `ConnectConfig.json` at `load()` time. The push
|
|
92
|
+
/// bridge methods branch on this synchronously rather than calling into the
|
|
93
|
+
/// `@MainActor` SDK to detect mode (mirrors the Android bridge): manual mode
|
|
94
|
+
/// forwards events to the SDK; automatic/off surface `EAC-RN-007` (`false`).
|
|
95
|
+
///
|
|
67
96
|
// Constructor — auto-inits the SDK from `ConnectConfig.json`. Matches the
|
|
68
97
|
// pre-CA-137696 behaviour; consumers that need consent-gated init can call
|
|
69
98
|
// `disable()` immediately and `enable()` once they have permission.
|
|
@@ -304,6 +333,154 @@ class HybridAcousticConnectRN: HybridAcousticConnectRNSpec {
|
|
|
304
333
|
return true
|
|
305
334
|
}
|
|
306
335
|
|
|
336
|
+
// MARK: - Push: APNs lifecycle (CA-144306)
|
|
337
|
+
|
|
338
|
+
/// Forwards the raw APNs device token to the SDK. Nitro hands us native
|
|
339
|
+
/// `Data` via `ArrayBuffer` — no hex conversion, no validation. Idempotent
|
|
340
|
+
/// in automatic mode (the SDK already captured the token via its swizzle).
|
|
341
|
+
///
|
|
342
|
+
/// Resolves `true` once the SDK accepted the token, `false` if the call was
|
|
343
|
+
/// rejected (e.g. push not enabled). Never rejects.
|
|
344
|
+
func pushDidRegisterWithToken(deviceToken: ArrayBuffer) throws -> Promise<Bool> {
|
|
345
|
+
let token = deviceToken.toData(copyIfNeeded: true)
|
|
346
|
+
return Promise.async { @MainActor in
|
|
347
|
+
do {
|
|
348
|
+
try ConnectSDK.shared.push.didRegisterWithToken(token)
|
|
349
|
+
return true
|
|
350
|
+
} catch {
|
|
351
|
+
bridgeLog.error("pushDidRegisterWithToken failed: \(error.localizedDescription, privacy: .public)")
|
|
352
|
+
return false
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/// Forwards an APNs registration failure to the SDK as an `NSError`.
|
|
358
|
+
/// Resolves `true` once forwarded, `false` on failure. Never rejects.
|
|
359
|
+
func pushDidFailToRegister(error: PushErrorInfo) throws -> Promise<Bool> {
|
|
360
|
+
let nsError = Self.nsError(from: error)
|
|
361
|
+
return Promise.async { @MainActor in
|
|
362
|
+
do {
|
|
363
|
+
try ConnectSDK.shared.push.didFailToRegisterWithError(nsError)
|
|
364
|
+
return true
|
|
365
|
+
} catch {
|
|
366
|
+
bridgeLog.error("pushDidFailToRegister failed: \(error.localizedDescription, privacy: .public)")
|
|
367
|
+
return false
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// MARK: - Push: notification delivery — manual mode only (CA-144307)
|
|
373
|
+
|
|
374
|
+
/// Forwards a received notification so the SDK logs `pushReceived` (manual
|
|
375
|
+
/// mode). Resolves `true` when processed. In automatic/off mode the SDK
|
|
376
|
+
/// throws `pushModeNotManual` (its own delegate already handles delivery);
|
|
377
|
+
/// the bridge catches it and resolves `false` — the `EAC-RN-007` surface.
|
|
378
|
+
/// Never rejects.
|
|
379
|
+
func pushDidReceiveNotification(userInfo: [String: Variant_Bool_String_Double]) throws -> Promise<Bool> {
|
|
380
|
+
let notification = HybridAcousticConnectNotification(userInfo: convertToAnyDictionary(input: userInfo))
|
|
381
|
+
return Promise.async { @MainActor in
|
|
382
|
+
do {
|
|
383
|
+
try ConnectSDK.shared.push.didReceiveNotification(notification)
|
|
384
|
+
return true
|
|
385
|
+
} catch {
|
|
386
|
+
bridgeLog.error("pushDidReceiveNotification failed: \(error.localizedDescription, privacy: .public)")
|
|
387
|
+
return false
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/// Forwards a notification response (tap / action) so the SDK runs the
|
|
393
|
+
/// built-in action and logs `pushAction` (manual mode). Resolves `true` when
|
|
394
|
+
/// processed; `false` (EAC-RN-007) in automatic/off mode via the same
|
|
395
|
+
/// caught `pushModeNotManual`. Never rejects.
|
|
396
|
+
func pushDidReceiveResponse(actionIdentifier: String, userInfo: [String: Variant_Bool_String_Double]) throws -> Promise<Bool> {
|
|
397
|
+
let response = HybridAcousticConnectNotificationResponse(
|
|
398
|
+
actionIdentifier: actionIdentifier,
|
|
399
|
+
userInfo: convertToAnyDictionary(input: userInfo)
|
|
400
|
+
)
|
|
401
|
+
return Promise.async { @MainActor in
|
|
402
|
+
do {
|
|
403
|
+
try ConnectSDK.shared.push.didReceive(response)
|
|
404
|
+
return true
|
|
405
|
+
} catch {
|
|
406
|
+
bridgeLog.error("pushDidReceiveResponse failed: \(error.localizedDescription, privacy: .public)")
|
|
407
|
+
return false
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// MARK: - Push: permission management (CA-144308)
|
|
413
|
+
|
|
414
|
+
/// Forwards externally-obtained permission state to the SDK. Tri-state
|
|
415
|
+
/// `granted`: `true`/`false` forward; `nil` (notDetermined) is recorded by
|
|
416
|
+
/// the OS, not forwarded — the SDK has no notion of an "unknown" state.
|
|
417
|
+
func pushDidReceiveAuthorization(granted: Variant_NullType_Bool?, error: PushErrorInfo?) throws -> Promise<Bool> {
|
|
418
|
+
// `nil` (notDetermined) is intentionally not forwarded — the SDK has no
|
|
419
|
+
// notion of an "unknown" authorization. This resolves `true` ("handled —
|
|
420
|
+
// accepted, not forwarded"), not a failure.
|
|
421
|
+
guard let triState = granted?.asType(Bool.self) else {
|
|
422
|
+
return Promise.resolved(withResult: true)
|
|
423
|
+
}
|
|
424
|
+
// Not gated on push mode: the SDK's didReceiveAuthorization is safe in
|
|
425
|
+
// both modes, so externally-obtained permission state is always forwarded.
|
|
426
|
+
let nsError = error.map(Self.nsError(from:))
|
|
427
|
+
return Promise.async { @MainActor in
|
|
428
|
+
do {
|
|
429
|
+
try ConnectSDK.shared.push.didReceiveAuthorization(granted: triState, error: nsError)
|
|
430
|
+
return true
|
|
431
|
+
} catch {
|
|
432
|
+
bridgeLog.error("pushDidReceiveAuthorization failed: \(error.localizedDescription, privacy: .public)")
|
|
433
|
+
return false
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/// Requests notification permission via the SDK, presenting the system
|
|
439
|
+
/// prompt when the status is undetermined, and resolves with the structured
|
|
440
|
+
/// result. Never rejects — a system error (or push-not-enabled) surfaces in
|
|
441
|
+
/// `error` with `granted: false`.
|
|
442
|
+
func pushRequestPermission() throws -> Promise<PushPermissionResult> {
|
|
443
|
+
return Promise.async { @MainActor in
|
|
444
|
+
do {
|
|
445
|
+
let result = try await ConnectSDK.shared.push.requestAuthorization()
|
|
446
|
+
let error: Variant_NullType_String? = result.error.map { .second($0.localizedDescription) }
|
|
447
|
+
return PushPermissionResult(granted: result.granted, error: error)
|
|
448
|
+
} catch {
|
|
449
|
+
bridgeLog.error("pushRequestPermission failed: \(error.localizedDescription, privacy: .public)")
|
|
450
|
+
return PushPermissionResult(granted: false, error: .second(error.localizedDescription))
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/// Reads the current notification permission state without prompting, mapped
|
|
456
|
+
/// to a tri-state: `true` granted, `false` denied, `null` not determined.
|
|
457
|
+
/// Never rejects — push-not-enabled resolves as `null`.
|
|
458
|
+
func pushGetPermissionState() throws -> Promise<Variant_NullType_Bool> {
|
|
459
|
+
return Promise.async { @MainActor in
|
|
460
|
+
do {
|
|
461
|
+
if let granted = try await ConnectSDK.shared.push.getCurrentAuthorization() {
|
|
462
|
+
return .second(granted)
|
|
463
|
+
}
|
|
464
|
+
return .first(.null)
|
|
465
|
+
} catch {
|
|
466
|
+
bridgeLog.error("pushGetPermissionState failed: \(error.localizedDescription, privacy: .public)")
|
|
467
|
+
return .first(.null)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// MARK: - Push: helpers
|
|
473
|
+
|
|
474
|
+
/// Builds an `NSError` from the structured bridge error object, shared by
|
|
475
|
+
/// `pushDidFailToRegister` and `pushDidReceiveAuthorization`.
|
|
476
|
+
private static func nsError(from info: PushErrorInfo) -> NSError {
|
|
477
|
+
NSError(
|
|
478
|
+
domain: info.domain ?? "ConnectRNBridge",
|
|
479
|
+
code: Int(info.code ?? -1),
|
|
480
|
+
userInfo: [NSLocalizedDescriptionKey: info.message]
|
|
481
|
+
)
|
|
482
|
+
}
|
|
483
|
+
|
|
307
484
|
/// Sets the module's configuration item from AdvancedConfig.json or BasicConfig.plist that matches the specified key as a BOOL value.
|
|
308
485
|
/// - Parameters:
|
|
309
486
|
/// - key: Key to update value in configuration settings.
|
|
@@ -4,6 +4,36 @@ export type KeyValueObject = {
|
|
|
4
4
|
[key: string]: unknown;
|
|
5
5
|
};
|
|
6
6
|
export type ConnectMonitoringLevelType = 'Ignore' | 'CellularAndWiFi' | 'WiFi';
|
|
7
|
+
/**
|
|
8
|
+
* Structured error describing an APNs / permission failure.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the `firebase-messaging` / `notifee` ecosystem convention so callers
|
|
11
|
+
* can forward a native error object without string-encoding it. The native
|
|
12
|
+
* bridge reconstructs an `NSError` (iOS) from these fields.
|
|
13
|
+
*/
|
|
14
|
+
export interface PushErrorInfo {
|
|
15
|
+
/** Platform error code, when available (maps to `NSError.code`). */
|
|
16
|
+
code?: number;
|
|
17
|
+
/** Platform error domain, when available (maps to `NSError.domain`). */
|
|
18
|
+
domain?: string;
|
|
19
|
+
/** Human-readable failure description (maps to `NSLocalizedDescriptionKey`). */
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of a permission request.
|
|
24
|
+
*
|
|
25
|
+
* The Promise from {@link AcousticConnectRN.pushRequestPermission} always
|
|
26
|
+
* resolves with this shape and never rejects. `error` is `null` on success or
|
|
27
|
+
* a denial with no system error; a non-null string carries the system error's
|
|
28
|
+
* localized description, or `'permission-prompt-abandoned'` if the host was
|
|
29
|
+
* destroyed mid-prompt.
|
|
30
|
+
*/
|
|
31
|
+
export interface PushPermissionResult {
|
|
32
|
+
/** `true` if the user granted permission, `false` otherwise. */
|
|
33
|
+
granted: boolean;
|
|
34
|
+
/** `null` on success/clean denial; otherwise a description of the error. */
|
|
35
|
+
error?: string | null;
|
|
36
|
+
}
|
|
7
37
|
export interface AcousticConnectRN extends HybridObject<{
|
|
8
38
|
ios: 'swift';
|
|
9
39
|
android: 'kotlin';
|
|
@@ -92,5 +122,84 @@ export interface AcousticConnectRN extends HybridObject<{
|
|
|
92
122
|
logDialogDismissEvent(dialogId: string, dismissReason: string): boolean;
|
|
93
123
|
logDialogButtonClickEvent(dialogId: string, buttonText: string, buttonIndex: number): boolean;
|
|
94
124
|
logDialogCustomEvent(dialogId: string, eventName: string, values: Record<string, string | number | boolean>): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Forwards the raw APNs device token to the Connect SDK (manual mode).
|
|
127
|
+
*
|
|
128
|
+
* Nitro maps `ArrayBuffer` ↔ `Data` natively; the bridge forwards the bytes
|
|
129
|
+
* unchanged with no hex conversion and no validation.
|
|
130
|
+
*
|
|
131
|
+
* @param deviceToken Raw APNs device-token bytes from
|
|
132
|
+
* `didRegisterForRemoteNotificationsWithDeviceToken`.
|
|
133
|
+
* @returns A promise resolving to `true` once the SDK accepted the token,
|
|
134
|
+
* or `false` if the SDK rejected the call (e.g. push not enabled). Never
|
|
135
|
+
* rejects.
|
|
136
|
+
*/
|
|
137
|
+
pushDidRegisterWithToken(deviceToken: ArrayBuffer): Promise<boolean>;
|
|
138
|
+
/**
|
|
139
|
+
* Forwards an APNs registration failure to the Connect SDK (manual mode).
|
|
140
|
+
*
|
|
141
|
+
* @param error Structured error; the bridge builds an `NSError` from it.
|
|
142
|
+
* @returns A promise resolving to `true` once forwarded, `false` on failure.
|
|
143
|
+
* Never rejects.
|
|
144
|
+
*/
|
|
145
|
+
pushDidFailToRegister(error: PushErrorInfo): Promise<boolean>;
|
|
146
|
+
/**
|
|
147
|
+
* Forwards a received notification to the Connect SDK so it can log a
|
|
148
|
+
* `pushReceived` signal (manual mode).
|
|
149
|
+
*
|
|
150
|
+
* The bridge branches on the push mode resolved from `ConnectConfig.json`:
|
|
151
|
+
* manual mode forwards to the SDK and returns `true`; automatic/off mode
|
|
152
|
+
* returns `false` (bridge error `EAC-RN-007`) without forwarding, because
|
|
153
|
+
* the SDK's own delegate already handles delivery in automatic mode and
|
|
154
|
+
* forwarding would double-log.
|
|
155
|
+
*
|
|
156
|
+
* @param userInfo The notification `userInfo` payload.
|
|
157
|
+
* @returns A promise resolving to `true` if processed (manual mode), or
|
|
158
|
+
* `false` in automatic/off mode (`EAC-RN-007`). Never rejects.
|
|
159
|
+
*/
|
|
160
|
+
pushDidReceiveNotification(userInfo: Record<string, string | number | boolean>): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Forwards a notification response (tap / action) to the Connect SDK so it
|
|
163
|
+
* can run the built-in action and log a `pushAction` signal (manual mode).
|
|
164
|
+
*
|
|
165
|
+
* Same `EAC-RN-007` (`false`) behaviour in automatic mode as
|
|
166
|
+
* {@link pushDidReceiveNotification}.
|
|
167
|
+
*
|
|
168
|
+
* @param actionIdentifier The response action identifier.
|
|
169
|
+
* @param userInfo The notification `userInfo` payload.
|
|
170
|
+
* @returns A promise resolving to `true` if processed (manual mode), or
|
|
171
|
+
* `false` in automatic/off mode (`EAC-RN-007`). Never rejects.
|
|
172
|
+
*/
|
|
173
|
+
pushDidReceiveResponse(actionIdentifier: string, userInfo: Record<string, string | number | boolean>): Promise<boolean>;
|
|
174
|
+
/**
|
|
175
|
+
* Forwards externally-obtained permission state to the SDK.
|
|
176
|
+
*
|
|
177
|
+
* Tri-state `granted`: `true` granted, `false` denied, `null` not yet
|
|
178
|
+
* determined. For `null` the bridge records the state but does not call the
|
|
179
|
+
* SDK (it has no notion of forwarding "unknown").
|
|
180
|
+
*
|
|
181
|
+
* @param granted Tri-state permission value.
|
|
182
|
+
* @param error Optional structured error accompanying a denial.
|
|
183
|
+
* @returns A promise resolving to `true` once handled — including the
|
|
184
|
+
* `null`/not-determined case, which is intentionally accepted without
|
|
185
|
+
* forwarding to the SDK. `false` only if the SDK rejected a forwarded
|
|
186
|
+
* state. Never rejects.
|
|
187
|
+
*/
|
|
188
|
+
pushDidReceiveAuthorization(granted: boolean | null, error?: PushErrorInfo): Promise<boolean>;
|
|
189
|
+
/**
|
|
190
|
+
* Requests notification permission via the SDK, presenting the system prompt
|
|
191
|
+
* when undetermined.
|
|
192
|
+
*
|
|
193
|
+
* Always resolves, never rejects — see {@link PushPermissionResult}.
|
|
194
|
+
*
|
|
195
|
+
* @returns The permission result.
|
|
196
|
+
*/
|
|
197
|
+
pushRequestPermission(): Promise<PushPermissionResult>;
|
|
198
|
+
/**
|
|
199
|
+
* Reads the current notification permission state without prompting.
|
|
200
|
+
*
|
|
201
|
+
* @returns Tri-state: `true` granted, `false` denied, `null` not determined.
|
|
202
|
+
*/
|
|
203
|
+
pushGetPermissionState(): Promise<boolean | null>;
|
|
95
204
|
}
|
|
96
205
|
//# sourceMappingURL=react-native-acoustic-connect.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-acoustic-connect.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/react-native-acoustic-connect.nitro.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAG9D,MAAM,MAAM,cAAc,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAA;AAE9E,MAAM,WAAW,iBAAkB,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAAM,IAAI,OAAO,CAAA;IAEjB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,IAAI,OAAO,CAAA;IAClB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;IACpF,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5E,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OAAO,CAAC,OAAO,CAAC,CAAA;IAE7F;;;;;;;OAOG;IACH,qBAAqB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAEtD;;;;OAIG;IACH,sBAAsB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;CACpD"}
|
|
@@ -37,6 +37,7 @@ target_sources(
|
|
|
37
37
|
# Android-specific Nitrogen C++ sources
|
|
38
38
|
../nitrogen/generated/android/c++/JHybridAcousticConnectRNSpec.cpp
|
|
39
39
|
../nitrogen/generated/android/c++/JVariant_NullType_String.cpp
|
|
40
|
+
../nitrogen/generated/android/c++/JVariant_NullType_Boolean.cpp
|
|
40
41
|
../nitrogen/generated/android/c++/JVariant_Boolean_String_Double.cpp
|
|
41
42
|
)
|
|
42
43
|
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridAcousticConnectRNSpec.hpp"
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// Forward declaration of `PushPermissionResult` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::acousticconnectrn { struct PushPermissionResult; }
|
|
12
|
+
// Forward declaration of `PushErrorInfo` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::acousticconnectrn { struct PushErrorInfo; }
|
|
11
14
|
|
|
12
15
|
#include <NitroModules/Null.hpp>
|
|
13
16
|
#include <string>
|
|
@@ -15,8 +18,17 @@
|
|
|
15
18
|
#include <optional>
|
|
16
19
|
#include "JVariant_NullType_String.hpp"
|
|
17
20
|
#include <NitroModules/JNull.hpp>
|
|
21
|
+
#include <NitroModules/Promise.hpp>
|
|
22
|
+
#include <NitroModules/JPromise.hpp>
|
|
23
|
+
#include "PushPermissionResult.hpp"
|
|
24
|
+
#include "JPushPermissionResult.hpp"
|
|
25
|
+
#include "JVariant_NullType_Boolean.hpp"
|
|
18
26
|
#include "JVariant_Boolean_String_Double.hpp"
|
|
19
27
|
#include <unordered_map>
|
|
28
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
29
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
30
|
+
#include "PushErrorInfo.hpp"
|
|
31
|
+
#include "JPushErrorInfo.hpp"
|
|
20
32
|
|
|
21
33
|
namespace margelo::nitro::acousticconnectrn {
|
|
22
34
|
|
|
@@ -189,5 +201,129 @@ namespace margelo::nitro::acousticconnectrn {
|
|
|
189
201
|
}());
|
|
190
202
|
return static_cast<bool>(__result);
|
|
191
203
|
}
|
|
204
|
+
std::shared_ptr<Promise<bool>> JHybridAcousticConnectRNSpec::pushDidRegisterWithToken(const std::shared_ptr<ArrayBuffer>& deviceToken) {
|
|
205
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JArrayBuffer::javaobject> /* deviceToken */)>("pushDidRegisterWithToken");
|
|
206
|
+
auto __result = method(_javaPart, JArrayBuffer::wrap(deviceToken));
|
|
207
|
+
return [&]() {
|
|
208
|
+
auto __promise = Promise<bool>::create();
|
|
209
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
210
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
211
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
212
|
+
});
|
|
213
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
214
|
+
jni::JniException __jniError(__throwable);
|
|
215
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
216
|
+
});
|
|
217
|
+
return __promise;
|
|
218
|
+
}();
|
|
219
|
+
}
|
|
220
|
+
std::shared_ptr<Promise<bool>> JHybridAcousticConnectRNSpec::pushDidFailToRegister(const PushErrorInfo& error) {
|
|
221
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JPushErrorInfo> /* error */)>("pushDidFailToRegister");
|
|
222
|
+
auto __result = method(_javaPart, JPushErrorInfo::fromCpp(error));
|
|
223
|
+
return [&]() {
|
|
224
|
+
auto __promise = Promise<bool>::create();
|
|
225
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
226
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
227
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
228
|
+
});
|
|
229
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
230
|
+
jni::JniException __jniError(__throwable);
|
|
231
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
232
|
+
});
|
|
233
|
+
return __promise;
|
|
234
|
+
}();
|
|
235
|
+
}
|
|
236
|
+
std::shared_ptr<Promise<bool>> JHybridAcousticConnectRNSpec::pushDidReceiveNotification(const std::unordered_map<std::string, std::variant<bool, std::string, double>>& userInfo) {
|
|
237
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JMap<jni::JString, JVariant_Boolean_String_Double>> /* userInfo */)>("pushDidReceiveNotification");
|
|
238
|
+
auto __result = method(_javaPart, [&]() -> jni::local_ref<jni::JMap<jni::JString, JVariant_Boolean_String_Double>> {
|
|
239
|
+
auto __map = jni::JHashMap<jni::JString, JVariant_Boolean_String_Double>::create(userInfo.size());
|
|
240
|
+
for (const auto& __entry : userInfo) {
|
|
241
|
+
__map->put(jni::make_jstring(__entry.first), JVariant_Boolean_String_Double::fromCpp(__entry.second));
|
|
242
|
+
}
|
|
243
|
+
return __map;
|
|
244
|
+
}());
|
|
245
|
+
return [&]() {
|
|
246
|
+
auto __promise = Promise<bool>::create();
|
|
247
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
248
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
249
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
250
|
+
});
|
|
251
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
252
|
+
jni::JniException __jniError(__throwable);
|
|
253
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
254
|
+
});
|
|
255
|
+
return __promise;
|
|
256
|
+
}();
|
|
257
|
+
}
|
|
258
|
+
std::shared_ptr<Promise<bool>> JHybridAcousticConnectRNSpec::pushDidReceiveResponse(const std::string& actionIdentifier, const std::unordered_map<std::string, std::variant<bool, std::string, double>>& userInfo) {
|
|
259
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* actionIdentifier */, jni::alias_ref<jni::JMap<jni::JString, JVariant_Boolean_String_Double>> /* userInfo */)>("pushDidReceiveResponse");
|
|
260
|
+
auto __result = method(_javaPart, jni::make_jstring(actionIdentifier), [&]() -> jni::local_ref<jni::JMap<jni::JString, JVariant_Boolean_String_Double>> {
|
|
261
|
+
auto __map = jni::JHashMap<jni::JString, JVariant_Boolean_String_Double>::create(userInfo.size());
|
|
262
|
+
for (const auto& __entry : userInfo) {
|
|
263
|
+
__map->put(jni::make_jstring(__entry.first), JVariant_Boolean_String_Double::fromCpp(__entry.second));
|
|
264
|
+
}
|
|
265
|
+
return __map;
|
|
266
|
+
}());
|
|
267
|
+
return [&]() {
|
|
268
|
+
auto __promise = Promise<bool>::create();
|
|
269
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
270
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
271
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
272
|
+
});
|
|
273
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
274
|
+
jni::JniException __jniError(__throwable);
|
|
275
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
276
|
+
});
|
|
277
|
+
return __promise;
|
|
278
|
+
}();
|
|
279
|
+
}
|
|
280
|
+
std::shared_ptr<Promise<bool>> JHybridAcousticConnectRNSpec::pushDidReceiveAuthorization(const std::optional<std::variant<nitro::NullType, bool>>& granted, const std::optional<PushErrorInfo>& error) {
|
|
281
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JVariant_NullType_Boolean> /* granted */, jni::alias_ref<JPushErrorInfo> /* error */)>("pushDidReceiveAuthorization");
|
|
282
|
+
auto __result = method(_javaPart, granted.has_value() ? JVariant_NullType_Boolean::fromCpp(granted.value()) : nullptr, error.has_value() ? JPushErrorInfo::fromCpp(error.value()) : nullptr);
|
|
283
|
+
return [&]() {
|
|
284
|
+
auto __promise = Promise<bool>::create();
|
|
285
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
286
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
287
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
288
|
+
});
|
|
289
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
290
|
+
jni::JniException __jniError(__throwable);
|
|
291
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
292
|
+
});
|
|
293
|
+
return __promise;
|
|
294
|
+
}();
|
|
295
|
+
}
|
|
296
|
+
std::shared_ptr<Promise<PushPermissionResult>> JHybridAcousticConnectRNSpec::pushRequestPermission() {
|
|
297
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pushRequestPermission");
|
|
298
|
+
auto __result = method(_javaPart);
|
|
299
|
+
return [&]() {
|
|
300
|
+
auto __promise = Promise<PushPermissionResult>::create();
|
|
301
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
302
|
+
auto __result = jni::static_ref_cast<JPushPermissionResult>(__boxedResult);
|
|
303
|
+
__promise->resolve(__result->toCpp());
|
|
304
|
+
});
|
|
305
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
306
|
+
jni::JniException __jniError(__throwable);
|
|
307
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
308
|
+
});
|
|
309
|
+
return __promise;
|
|
310
|
+
}();
|
|
311
|
+
}
|
|
312
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, bool>>> JHybridAcousticConnectRNSpec::pushGetPermissionState() {
|
|
313
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pushGetPermissionState");
|
|
314
|
+
auto __result = method(_javaPart);
|
|
315
|
+
return [&]() {
|
|
316
|
+
auto __promise = Promise<std::variant<nitro::NullType, bool>>::create();
|
|
317
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
318
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_Boolean>(__boxedResult);
|
|
319
|
+
__promise->resolve(__result->toCpp());
|
|
320
|
+
});
|
|
321
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
322
|
+
jni::JniException __jniError(__throwable);
|
|
323
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
324
|
+
});
|
|
325
|
+
return __promise;
|
|
326
|
+
}();
|
|
327
|
+
}
|
|
192
328
|
|
|
193
329
|
} // namespace margelo::nitro::acousticconnectrn
|
|
@@ -78,6 +78,13 @@ namespace margelo::nitro::acousticconnectrn {
|
|
|
78
78
|
bool logDialogDismissEvent(const std::string& dialogId, const std::string& dismissReason) override;
|
|
79
79
|
bool logDialogButtonClickEvent(const std::string& dialogId, const std::string& buttonText, double buttonIndex) override;
|
|
80
80
|
bool logDialogCustomEvent(const std::string& dialogId, const std::string& eventName, const std::unordered_map<std::string, std::variant<bool, std::string, double>>& values) override;
|
|
81
|
+
std::shared_ptr<Promise<bool>> pushDidRegisterWithToken(const std::shared_ptr<ArrayBuffer>& deviceToken) override;
|
|
82
|
+
std::shared_ptr<Promise<bool>> pushDidFailToRegister(const PushErrorInfo& error) override;
|
|
83
|
+
std::shared_ptr<Promise<bool>> pushDidReceiveNotification(const std::unordered_map<std::string, std::variant<bool, std::string, double>>& userInfo) override;
|
|
84
|
+
std::shared_ptr<Promise<bool>> pushDidReceiveResponse(const std::string& actionIdentifier, const std::unordered_map<std::string, std::variant<bool, std::string, double>>& userInfo) override;
|
|
85
|
+
std::shared_ptr<Promise<bool>> pushDidReceiveAuthorization(const std::optional<std::variant<nitro::NullType, bool>>& granted, const std::optional<PushErrorInfo>& error) override;
|
|
86
|
+
std::shared_ptr<Promise<PushPermissionResult>> pushRequestPermission() override;
|
|
87
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, bool>>> pushGetPermissionState() override;
|
|
81
88
|
|
|
82
89
|
private:
|
|
83
90
|
jni::global_ref<JHybridAcousticConnectRNSpec::JavaPart> _javaPart;
|