@onekeyfe/react-native-device-utils 1.1.19 → 1.1.21
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/ReactNativeDeviceUtils.podspec +1 -0
- package/android/build.gradle +5 -0
- package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +153 -8
- package/ios/ReactNativeDeviceUtils.swift +109 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +22 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JGooglePlayServicesStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +145 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +9 -0
- package/nitrogen/generated/android/c++/JLaunchOptions.hpp +62 -0
- package/nitrogen/generated/android/c++/JWebViewPackageInfo.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/GooglePlayServicesStatus.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/LaunchOptions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WebViewPackageInfo.kt +44 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +48 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +305 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +81 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_GooglePlayServicesStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_LaunchOptions.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_WebViewPackageInfo.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/GooglePlayServicesStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +9 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +163 -0
- package/nitrogen/generated/ios/swift/LaunchOptions.swift +66 -0
- package/nitrogen/generated/ios/swift/WebViewPackageInfo.swift +58 -0
- package/nitrogen/generated/shared/c++/GooglePlayServicesStatus.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +9 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +19 -0
- package/nitrogen/generated/shared/c++/LaunchOptions.hpp +80 -0
- package/nitrogen/generated/shared/c++/WebViewPackageInfo.hpp +83 -0
- package/package.json +1 -1
- package/src/ReactNativeDeviceUtils.nitro.ts +31 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_double.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: Double) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_double {
|
|
16
|
+
public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: Double) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: Double) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: Double) -> Void {
|
|
26
|
+
self.closure(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_double`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_double>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double {
|
|
45
|
+
return Unmanaged<Func_void_double>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: String) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__string {
|
|
16
|
+
public typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: String) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: String) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: std.string) -> Void {
|
|
26
|
+
self.closure(String(value))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__string`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
45
|
+
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GooglePlayServicesStatus.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `GooglePlayServicesStatus`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias GooglePlayServicesStatus = margelo.nitro.reactnativedeviceutils.GooglePlayServicesStatus
|
|
15
|
+
|
|
16
|
+
public extension GooglePlayServicesStatus {
|
|
17
|
+
private typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `GooglePlayServicesStatus`.
|
|
21
|
+
*/
|
|
22
|
+
init(status: Double, isAvailable: Bool) {
|
|
23
|
+
self.init(status, isAvailable)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var status: Double {
|
|
27
|
+
@inline(__always)
|
|
28
|
+
get {
|
|
29
|
+
return self.__status
|
|
30
|
+
}
|
|
31
|
+
@inline(__always)
|
|
32
|
+
set {
|
|
33
|
+
self.__status = newValue
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var isAvailable: Bool {
|
|
38
|
+
@inline(__always)
|
|
39
|
+
get {
|
|
40
|
+
return self.__isAvailable
|
|
41
|
+
}
|
|
42
|
+
@inline(__always)
|
|
43
|
+
set {
|
|
44
|
+
self.__isAvailable = newValue
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -23,6 +23,15 @@ public protocol HybridReactNativeDeviceUtilsSpec_protocol: HybridObject {
|
|
|
23
23
|
func addSpanningChangedListener(callback: @escaping (_ isSpanning: Bool) -> Void) throws -> Double
|
|
24
24
|
func removeSpanningChangedListener(id: Double) throws -> Void
|
|
25
25
|
func setUserInterfaceStyle(style: UserInterfaceStyle) throws -> Void
|
|
26
|
+
func getLaunchOptions() throws -> Promise<LaunchOptions>
|
|
27
|
+
func clearLaunchOptions() throws -> Promise<Bool>
|
|
28
|
+
func getDeviceToken() throws -> Promise<String>
|
|
29
|
+
func saveDeviceToken(token: String) throws -> Promise<Void>
|
|
30
|
+
func registerDeviceToken() throws -> Promise<Bool>
|
|
31
|
+
func getStartupTime() throws -> Promise<Double>
|
|
32
|
+
func exitApp() throws -> Void
|
|
33
|
+
func getCurrentWebViewPackageInfo() throws -> Promise<WebViewPackageInfo>
|
|
34
|
+
func isGooglePlayServicesAvailable() throws -> Promise<GooglePlayServicesStatus>
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
public extension HybridReactNativeDeviceUtilsSpec_protocol {
|
|
@@ -245,4 +245,167 @@ open class HybridReactNativeDeviceUtilsSpec_cxx {
|
|
|
245
245
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
@inline(__always)
|
|
250
|
+
public final func getLaunchOptions() -> bridge.Result_std__shared_ptr_Promise_LaunchOptions___ {
|
|
251
|
+
do {
|
|
252
|
+
let __result = try self.__implementation.getLaunchOptions()
|
|
253
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_LaunchOptions__ in
|
|
254
|
+
let __promise = bridge.create_std__shared_ptr_Promise_LaunchOptions__()
|
|
255
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_LaunchOptions__(__promise)
|
|
256
|
+
__result
|
|
257
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
258
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
259
|
+
return __promise
|
|
260
|
+
}()
|
|
261
|
+
return bridge.create_Result_std__shared_ptr_Promise_LaunchOptions___(__resultCpp)
|
|
262
|
+
} catch (let __error) {
|
|
263
|
+
let __exceptionPtr = __error.toCpp()
|
|
264
|
+
return bridge.create_Result_std__shared_ptr_Promise_LaunchOptions___(__exceptionPtr)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@inline(__always)
|
|
269
|
+
public final func clearLaunchOptions() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
270
|
+
do {
|
|
271
|
+
let __result = try self.__implementation.clearLaunchOptions()
|
|
272
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
273
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
274
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
275
|
+
__result
|
|
276
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
277
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
278
|
+
return __promise
|
|
279
|
+
}()
|
|
280
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
281
|
+
} catch (let __error) {
|
|
282
|
+
let __exceptionPtr = __error.toCpp()
|
|
283
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@inline(__always)
|
|
288
|
+
public final func getDeviceToken() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
289
|
+
do {
|
|
290
|
+
let __result = try self.__implementation.getDeviceToken()
|
|
291
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
292
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
293
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
294
|
+
__result
|
|
295
|
+
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
296
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
297
|
+
return __promise
|
|
298
|
+
}()
|
|
299
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
300
|
+
} catch (let __error) {
|
|
301
|
+
let __exceptionPtr = __error.toCpp()
|
|
302
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@inline(__always)
|
|
307
|
+
public final func saveDeviceToken(token: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
308
|
+
do {
|
|
309
|
+
let __result = try self.__implementation.saveDeviceToken(token: String(token))
|
|
310
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
311
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
312
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
313
|
+
__result
|
|
314
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
315
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
316
|
+
return __promise
|
|
317
|
+
}()
|
|
318
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
319
|
+
} catch (let __error) {
|
|
320
|
+
let __exceptionPtr = __error.toCpp()
|
|
321
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@inline(__always)
|
|
326
|
+
public final func registerDeviceToken() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
327
|
+
do {
|
|
328
|
+
let __result = try self.__implementation.registerDeviceToken()
|
|
329
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
330
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
331
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
332
|
+
__result
|
|
333
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
334
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
335
|
+
return __promise
|
|
336
|
+
}()
|
|
337
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
338
|
+
} catch (let __error) {
|
|
339
|
+
let __exceptionPtr = __error.toCpp()
|
|
340
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@inline(__always)
|
|
345
|
+
public final func getStartupTime() -> bridge.Result_std__shared_ptr_Promise_double___ {
|
|
346
|
+
do {
|
|
347
|
+
let __result = try self.__implementation.getStartupTime()
|
|
348
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_double__ in
|
|
349
|
+
let __promise = bridge.create_std__shared_ptr_Promise_double__()
|
|
350
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_double__(__promise)
|
|
351
|
+
__result
|
|
352
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
353
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
354
|
+
return __promise
|
|
355
|
+
}()
|
|
356
|
+
return bridge.create_Result_std__shared_ptr_Promise_double___(__resultCpp)
|
|
357
|
+
} catch (let __error) {
|
|
358
|
+
let __exceptionPtr = __error.toCpp()
|
|
359
|
+
return bridge.create_Result_std__shared_ptr_Promise_double___(__exceptionPtr)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@inline(__always)
|
|
364
|
+
public final func exitApp() -> bridge.Result_void_ {
|
|
365
|
+
do {
|
|
366
|
+
try self.__implementation.exitApp()
|
|
367
|
+
return bridge.create_Result_void_()
|
|
368
|
+
} catch (let __error) {
|
|
369
|
+
let __exceptionPtr = __error.toCpp()
|
|
370
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@inline(__always)
|
|
375
|
+
public final func getCurrentWebViewPackageInfo() -> bridge.Result_std__shared_ptr_Promise_WebViewPackageInfo___ {
|
|
376
|
+
do {
|
|
377
|
+
let __result = try self.__implementation.getCurrentWebViewPackageInfo()
|
|
378
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_WebViewPackageInfo__ in
|
|
379
|
+
let __promise = bridge.create_std__shared_ptr_Promise_WebViewPackageInfo__()
|
|
380
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_WebViewPackageInfo__(__promise)
|
|
381
|
+
__result
|
|
382
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
383
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
384
|
+
return __promise
|
|
385
|
+
}()
|
|
386
|
+
return bridge.create_Result_std__shared_ptr_Promise_WebViewPackageInfo___(__resultCpp)
|
|
387
|
+
} catch (let __error) {
|
|
388
|
+
let __exceptionPtr = __error.toCpp()
|
|
389
|
+
return bridge.create_Result_std__shared_ptr_Promise_WebViewPackageInfo___(__exceptionPtr)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@inline(__always)
|
|
394
|
+
public final func isGooglePlayServicesAvailable() -> bridge.Result_std__shared_ptr_Promise_GooglePlayServicesStatus___ {
|
|
395
|
+
do {
|
|
396
|
+
let __result = try self.__implementation.isGooglePlayServicesAvailable()
|
|
397
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_GooglePlayServicesStatus__ in
|
|
398
|
+
let __promise = bridge.create_std__shared_ptr_Promise_GooglePlayServicesStatus__()
|
|
399
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_GooglePlayServicesStatus__(__promise)
|
|
400
|
+
__result
|
|
401
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
402
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
403
|
+
return __promise
|
|
404
|
+
}()
|
|
405
|
+
return bridge.create_Result_std__shared_ptr_Promise_GooglePlayServicesStatus___(__resultCpp)
|
|
406
|
+
} catch (let __error) {
|
|
407
|
+
let __exceptionPtr = __error.toCpp()
|
|
408
|
+
return bridge.create_Result_std__shared_ptr_Promise_GooglePlayServicesStatus___(__exceptionPtr)
|
|
409
|
+
}
|
|
410
|
+
}
|
|
248
411
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LaunchOptions.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `LaunchOptions`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias LaunchOptions = margelo.nitro.reactnativedeviceutils.LaunchOptions
|
|
15
|
+
|
|
16
|
+
public extension LaunchOptions {
|
|
17
|
+
private typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `LaunchOptions`.
|
|
21
|
+
*/
|
|
22
|
+
init(launchType: String, deepLink: String?) {
|
|
23
|
+
self.init(std.string(launchType), { () -> bridge.std__optional_std__string_ in
|
|
24
|
+
if let __unwrappedValue = deepLink {
|
|
25
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
26
|
+
} else {
|
|
27
|
+
return .init()
|
|
28
|
+
}
|
|
29
|
+
}())
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var launchType: String {
|
|
33
|
+
@inline(__always)
|
|
34
|
+
get {
|
|
35
|
+
return String(self.__launchType)
|
|
36
|
+
}
|
|
37
|
+
@inline(__always)
|
|
38
|
+
set {
|
|
39
|
+
self.__launchType = std.string(newValue)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var deepLink: String? {
|
|
44
|
+
@inline(__always)
|
|
45
|
+
get {
|
|
46
|
+
return { () -> String? in
|
|
47
|
+
if bridge.has_value_std__optional_std__string_(self.__deepLink) {
|
|
48
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__deepLink)
|
|
49
|
+
return String(__unwrapped)
|
|
50
|
+
} else {
|
|
51
|
+
return nil
|
|
52
|
+
}
|
|
53
|
+
}()
|
|
54
|
+
}
|
|
55
|
+
@inline(__always)
|
|
56
|
+
set {
|
|
57
|
+
self.__deepLink = { () -> bridge.std__optional_std__string_ in
|
|
58
|
+
if let __unwrappedValue = newValue {
|
|
59
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
60
|
+
} else {
|
|
61
|
+
return .init()
|
|
62
|
+
}
|
|
63
|
+
}()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WebViewPackageInfo.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `WebViewPackageInfo`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias WebViewPackageInfo = margelo.nitro.reactnativedeviceutils.WebViewPackageInfo
|
|
15
|
+
|
|
16
|
+
public extension WebViewPackageInfo {
|
|
17
|
+
private typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `WebViewPackageInfo`.
|
|
21
|
+
*/
|
|
22
|
+
init(packageName: String, versionName: String, versionCode: Double) {
|
|
23
|
+
self.init(std.string(packageName), std.string(versionName), versionCode)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var packageName: String {
|
|
27
|
+
@inline(__always)
|
|
28
|
+
get {
|
|
29
|
+
return String(self.__packageName)
|
|
30
|
+
}
|
|
31
|
+
@inline(__always)
|
|
32
|
+
set {
|
|
33
|
+
self.__packageName = std.string(newValue)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var versionName: String {
|
|
38
|
+
@inline(__always)
|
|
39
|
+
get {
|
|
40
|
+
return String(self.__versionName)
|
|
41
|
+
}
|
|
42
|
+
@inline(__always)
|
|
43
|
+
set {
|
|
44
|
+
self.__versionName = std.string(newValue)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var versionCode: Double {
|
|
49
|
+
@inline(__always)
|
|
50
|
+
get {
|
|
51
|
+
return self.__versionCode
|
|
52
|
+
}
|
|
53
|
+
@inline(__always)
|
|
54
|
+
set {
|
|
55
|
+
self.__versionCode = newValue
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GooglePlayServicesStatus.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (GooglePlayServicesStatus).
|
|
34
|
+
*/
|
|
35
|
+
struct GooglePlayServicesStatus {
|
|
36
|
+
public:
|
|
37
|
+
double status SWIFT_PRIVATE;
|
|
38
|
+
bool isAvailable SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
GooglePlayServicesStatus() = default;
|
|
42
|
+
explicit GooglePlayServicesStatus(double status, bool isAvailable): status(status), isAvailable(isAvailable) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
// C++ GooglePlayServicesStatus <> JS GooglePlayServicesStatus (object)
|
|
50
|
+
template <>
|
|
51
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus> final {
|
|
52
|
+
static inline margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
+
return margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus(
|
|
55
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "status")),
|
|
56
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isAvailable"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "status", JSIConverter<double>::toJSI(runtime, arg.status));
|
|
62
|
+
obj.setProperty(runtime, "isAvailable", JSIConverter<bool>::toJSI(runtime, arg.isAvailable));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "status"))) return false;
|
|
74
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isAvailable"))) return false;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro
|
|
@@ -23,6 +23,15 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
23
23
|
prototype.registerHybridMethod("addSpanningChangedListener", &HybridReactNativeDeviceUtilsSpec::addSpanningChangedListener);
|
|
24
24
|
prototype.registerHybridMethod("removeSpanningChangedListener", &HybridReactNativeDeviceUtilsSpec::removeSpanningChangedListener);
|
|
25
25
|
prototype.registerHybridMethod("setUserInterfaceStyle", &HybridReactNativeDeviceUtilsSpec::setUserInterfaceStyle);
|
|
26
|
+
prototype.registerHybridMethod("getLaunchOptions", &HybridReactNativeDeviceUtilsSpec::getLaunchOptions);
|
|
27
|
+
prototype.registerHybridMethod("clearLaunchOptions", &HybridReactNativeDeviceUtilsSpec::clearLaunchOptions);
|
|
28
|
+
prototype.registerHybridMethod("getDeviceToken", &HybridReactNativeDeviceUtilsSpec::getDeviceToken);
|
|
29
|
+
prototype.registerHybridMethod("saveDeviceToken", &HybridReactNativeDeviceUtilsSpec::saveDeviceToken);
|
|
30
|
+
prototype.registerHybridMethod("registerDeviceToken", &HybridReactNativeDeviceUtilsSpec::registerDeviceToken);
|
|
31
|
+
prototype.registerHybridMethod("getStartupTime", &HybridReactNativeDeviceUtilsSpec::getStartupTime);
|
|
32
|
+
prototype.registerHybridMethod("exitApp", &HybridReactNativeDeviceUtilsSpec::exitApp);
|
|
33
|
+
prototype.registerHybridMethod("getCurrentWebViewPackageInfo", &HybridReactNativeDeviceUtilsSpec::getCurrentWebViewPackageInfo);
|
|
34
|
+
prototype.registerHybridMethod("isGooglePlayServicesAvailable", &HybridReactNativeDeviceUtilsSpec::isGooglePlayServicesAvailable);
|
|
26
35
|
});
|
|
27
36
|
}
|
|
28
37
|
|
|
@@ -17,12 +17,22 @@
|
|
|
17
17
|
namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
|
|
18
18
|
// Forward declaration of `UserInterfaceStyle` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle; }
|
|
20
|
+
// Forward declaration of `LaunchOptions` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
|
|
22
|
+
// Forward declaration of `WebViewPackageInfo` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
|
|
24
|
+
// Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
|
|
20
26
|
|
|
21
27
|
#include "DualScreenInfoRect.hpp"
|
|
22
28
|
#include <vector>
|
|
23
29
|
#include <NitroModules/Promise.hpp>
|
|
24
30
|
#include <functional>
|
|
25
31
|
#include "UserInterfaceStyle.hpp"
|
|
32
|
+
#include "LaunchOptions.hpp"
|
|
33
|
+
#include <string>
|
|
34
|
+
#include "WebViewPackageInfo.hpp"
|
|
35
|
+
#include "GooglePlayServicesStatus.hpp"
|
|
26
36
|
|
|
27
37
|
namespace margelo::nitro::reactnativedeviceutils {
|
|
28
38
|
|
|
@@ -64,6 +74,15 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
64
74
|
virtual double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) = 0;
|
|
65
75
|
virtual void removeSpanningChangedListener(double id) = 0;
|
|
66
76
|
virtual void setUserInterfaceStyle(UserInterfaceStyle style) = 0;
|
|
77
|
+
virtual std::shared_ptr<Promise<LaunchOptions>> getLaunchOptions() = 0;
|
|
78
|
+
virtual std::shared_ptr<Promise<bool>> clearLaunchOptions() = 0;
|
|
79
|
+
virtual std::shared_ptr<Promise<std::string>> getDeviceToken() = 0;
|
|
80
|
+
virtual std::shared_ptr<Promise<void>> saveDeviceToken(const std::string& token) = 0;
|
|
81
|
+
virtual std::shared_ptr<Promise<bool>> registerDeviceToken() = 0;
|
|
82
|
+
virtual std::shared_ptr<Promise<double>> getStartupTime() = 0;
|
|
83
|
+
virtual void exitApp() = 0;
|
|
84
|
+
virtual std::shared_ptr<Promise<WebViewPackageInfo>> getCurrentWebViewPackageInfo() = 0;
|
|
85
|
+
virtual std::shared_ptr<Promise<GooglePlayServicesStatus>> isGooglePlayServicesAvailable() = 0;
|
|
67
86
|
|
|
68
87
|
protected:
|
|
69
88
|
// Hybrid Setup
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LaunchOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (LaunchOptions).
|
|
35
|
+
*/
|
|
36
|
+
struct LaunchOptions {
|
|
37
|
+
public:
|
|
38
|
+
std::string launchType SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> deepLink SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
LaunchOptions() = default;
|
|
43
|
+
explicit LaunchOptions(std::string launchType, std::optional<std::string> deepLink): launchType(launchType), deepLink(deepLink) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ LaunchOptions <> JS LaunchOptions (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::LaunchOptions> final {
|
|
53
|
+
static inline margelo::nitro::reactnativedeviceutils::LaunchOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::reactnativedeviceutils::LaunchOptions(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "launchType")),
|
|
57
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "deepLink"))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::LaunchOptions& arg) {
|
|
61
|
+
jsi::Object obj(runtime);
|
|
62
|
+
obj.setProperty(runtime, "launchType", JSIConverter<std::string>::toJSI(runtime, arg.launchType));
|
|
63
|
+
obj.setProperty(runtime, "deepLink", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.deepLink));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "launchType"))) return false;
|
|
75
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "deepLink"))) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|