@os1-platform/dispatch-mobile 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/android/.gradle/7.5/fileHashes/fileHashes.lock +0 -0
  2. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  3. package/android/.idea/caches/deviceStreaming.xml +11 -0
  4. package/android/build.gradle +1 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/com/dispatchsdk/DispatchSdkPackage.kt +5 -1
  7. package/android/src/main/java/com/dispatchsdk/location/LocationModule.kt +79 -0
  8. package/android/src/main/java/com/dispatchsdk/permissions/PermissionModule.kt +90 -0
  9. package/ios/EventEmitter.swift +13 -1
  10. package/ios/LocationManager.swift +143 -0
  11. package/ios/LocationModule.m +19 -0
  12. package/ios/LocationModule.swift +32 -0
  13. package/ios/PermissionsModule.m +21 -0
  14. package/ios/PermissionsModule.swift +24 -0
  15. package/ios/RNEventEmitter.m +2 -8
  16. package/ios/RNEventEmitter.swift +13 -19
  17. package/lib/commonjs/components/executiontasks/doodle/SignatureET.js +5 -3
  18. package/lib/commonjs/components/executiontasks/doodle/SignatureET.js.map +1 -1
  19. package/lib/commonjs/components/executiontasks/imageCapture/ImageCapture.js +5 -3
  20. package/lib/commonjs/components/executiontasks/imageCapture/ImageCapture.js.map +1 -1
  21. package/lib/commonjs/manager/location/LocationManager.js +91 -46
  22. package/lib/commonjs/manager/location/LocationManager.js.map +1 -1
  23. package/lib/commonjs/native/LocationModule.js +47 -0
  24. package/lib/commonjs/native/LocationModule.js.map +1 -0
  25. package/lib/commonjs/native/PermissionModule.js +21 -0
  26. package/lib/commonjs/native/PermissionModule.js.map +1 -0
  27. package/lib/commonjs/utils/ExecTaskUtils.js +3 -3
  28. package/lib/commonjs/utils/ExecTaskUtils.js.map +1 -1
  29. package/lib/commonjs/utils/SdkUtils.js +12 -4
  30. package/lib/commonjs/utils/SdkUtils.js.map +1 -1
  31. package/lib/module/components/executiontasks/doodle/SignatureET.js +5 -3
  32. package/lib/module/components/executiontasks/doodle/SignatureET.js.map +1 -1
  33. package/lib/module/components/executiontasks/imageCapture/ImageCapture.js +5 -3
  34. package/lib/module/components/executiontasks/imageCapture/ImageCapture.js.map +1 -1
  35. package/lib/module/manager/location/LocationManager.js +90 -44
  36. package/lib/module/manager/location/LocationManager.js.map +1 -1
  37. package/lib/module/native/LocationModule.js +41 -0
  38. package/lib/module/native/LocationModule.js.map +1 -0
  39. package/lib/module/native/PermissionModule.js +15 -0
  40. package/lib/module/native/PermissionModule.js.map +1 -0
  41. package/lib/module/utils/ExecTaskUtils.js +3 -3
  42. package/lib/module/utils/ExecTaskUtils.js.map +1 -1
  43. package/lib/module/utils/SdkUtils.js +12 -4
  44. package/lib/module/utils/SdkUtils.js.map +1 -1
  45. package/lib/typescript/manager/location/LocationManager.d.ts +4 -2
  46. package/lib/typescript/native/LocationModule.d.ts +14 -0
  47. package/lib/typescript/native/PermissionModule.d.ts +6 -0
  48. package/package.json +4 -4
  49. package/src/components/executiontasks/doodle/SignatureET.tsx +6 -4
  50. package/src/components/executiontasks/imageCapture/ImageCapture.tsx +6 -3
  51. package/src/manager/location/LocationManager.ts +93 -41
  52. package/src/native/LocationModule.ts +52 -0
  53. package/src/native/PermissionModule.ts +21 -0
  54. package/src/utils/ExecTaskUtils.ts +3 -3
  55. package/src/utils/SdkUtils.ts +15 -5
@@ -14,6 +14,17 @@
14
14
  <option name="screenX" value="720" />
15
15
  <option name="screenY" value="1280" />
16
16
  </PersistentDeviceSelectionData>
17
+ <PersistentDeviceSelectionData>
18
+ <option name="api" value="34" />
19
+ <option name="brand" value="OPPO" />
20
+ <option name="codename" value="OP573DL1" />
21
+ <option name="id" value="OP573DL1" />
22
+ <option name="manufacturer" value="OPPO" />
23
+ <option name="name" value="CPH2557" />
24
+ <option name="screenDensity" value="480" />
25
+ <option name="screenX" value="1080" />
26
+ <option name="screenY" value="2400" />
27
+ </PersistentDeviceSelectionData>
17
28
  <PersistentDeviceSelectionData>
18
29
  <option name="api" value="28" />
19
30
  <option name="brand" value="DOCOMO" />
@@ -127,4 +127,5 @@ dependencies {
127
127
  api 'com.facebook.react:react-native:+'
128
128
  implementation 'com.google.android.material:material:1.4.0'
129
129
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
130
+ implementation 'com.google.android.gms:play-services-location:20.0.0'
130
131
  }
@@ -1,6 +1,7 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="com.dispatchsdk">
3
3
 
4
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
4
5
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
5
6
  <uses-permission android:name="android.permission.WAKE_LOCK" />
6
7
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@@ -1,9 +1,11 @@
1
1
  package com.dispatchsdk
2
2
 
3
+ import com.dispatchsdk.location.LocationModule
3
4
  import com.dispatchsdk.sharedPref.SharedPreferenceModule
4
5
  import com.dispatchsdk.signaturePad.RSSignatureCaptureViewManager
5
6
  import com.dispatchsdk.sync.SyncModule
6
7
  import com.dispatchsdk.utils.DispatchSdkUtils
8
+ import com.dispatchsdk.permissions.PermissionsModule
7
9
  import com.facebook.react.ReactPackage
8
10
  import com.facebook.react.bridge.NativeModule
9
11
  import com.facebook.react.bridge.ReactApplicationContext
@@ -15,7 +17,9 @@ class DispatchSdkPackage : ReactPackage {
15
17
  return listOf(
16
18
  SyncModule(reactContext),
17
19
  DispatchSdkUtils(reactContext),
18
- SharedPreferenceModule(reactContext)
20
+ SharedPreferenceModule(reactContext),
21
+ PermissionsModule(reactContext),
22
+ LocationModule(reactContext)
19
23
  )
20
24
  }
21
25
 
@@ -0,0 +1,79 @@
1
+ package com.dispatchsdk.location
2
+
3
+ import android.Manifest
4
+ import android.content.pm.PackageManager
5
+ import android.location.Location
6
+ import android.os.Looper
7
+ import androidx.core.app.ActivityCompat
8
+ import com.facebook.react.bridge.*
9
+ import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
10
+ import com.google.android.gms.location.*
11
+
12
+ class LocationModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
13
+ private val fusedLocationClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(reactContext)
14
+ private var locationCallback: LocationCallback? = null
15
+ private var lastLocation: Location? = null
16
+
17
+ override fun getName(): String {
18
+ return "LocationModule"
19
+ }
20
+
21
+ @ReactMethod
22
+ fun startLocationUpdates(promise: Promise) {
23
+ val activity = currentActivity
24
+ if (activity == null) {
25
+ promise.reject("Activity doesn't exist")
26
+ return
27
+ }
28
+
29
+ if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
30
+ ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
31
+ promise.reject("Permissions not granted")
32
+ return
33
+ }
34
+
35
+ val locationRequest = LocationRequest.create().apply {
36
+ interval = 10000 // 10 seconds
37
+ fastestInterval = 10000 // 10 seconds
38
+ priority = LocationRequest.PRIORITY_HIGH_ACCURACY
39
+ smallestDisplacement = 10f // 10 meters
40
+ }
41
+
42
+ locationCallback = object : LocationCallback() {
43
+ override fun onLocationResult(locationResult: LocationResult) {
44
+ locationResult.lastLocation?.let { location ->
45
+ lastLocation = location
46
+ // Send location update to JavaScript
47
+ val params = Arguments.createMap()
48
+ params.putDouble("latitude", location.latitude)
49
+ params.putDouble("longitude", location.longitude)
50
+ params.putDouble("accuracy", location.accuracy.toDouble())
51
+ sendEvent("locationUpdated", params)
52
+ }
53
+ }
54
+ }
55
+
56
+ try {
57
+ fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback!!, Looper.getMainLooper())
58
+ promise.resolve("Location updates started")
59
+ } catch (e: Exception) {
60
+ promise.reject("Error starting location updates", e)
61
+ }
62
+ }
63
+
64
+ @ReactMethod
65
+ fun stopLocationUpdates(promise: Promise) {
66
+ locationCallback?.let {
67
+ fusedLocationClient.removeLocationUpdates(it)
68
+ promise.resolve("Location updates stopped")
69
+ } ?: run {
70
+ promise.reject("Location updates not started")
71
+ }
72
+ }
73
+
74
+ private fun sendEvent(eventName: String, params: WritableMap) {
75
+ reactApplicationContext
76
+ .getJSModule(RCTDeviceEventEmitter::class.java)
77
+ .emit(eventName, params)
78
+ }
79
+ }
@@ -0,0 +1,90 @@
1
+ package com.dispatchsdk.permissions
2
+
3
+ import android.Manifest
4
+ import android.app.Activity
5
+ import android.content.pm.PackageManager
6
+ import android.os.Build
7
+ import androidx.activity.ComponentActivity
8
+ import androidx.activity.result.contract.ActivityResultContracts
9
+ import androidx.annotation.RequiresApi
10
+ import androidx.core.content.ContextCompat
11
+ import com.facebook.react.bridge.*
12
+
13
+ class PermissionsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
14
+ companion object {
15
+ private const val REQUEST_CODE_FOREGROUND = 1
16
+ private const val REQUEST_CODE_BACKGROUND = 2
17
+ }
18
+
19
+ private var foregroundPromise: Promise? = null
20
+ private var backgroundPromise: Promise? = null
21
+
22
+ override fun getName(): String {
23
+ return "PermissionsModule"
24
+ }
25
+
26
+ private val requestForegroundPermissionLauncher = (reactContext.currentActivity as? ComponentActivity)?.registerForActivityResult(
27
+ ActivityResultContracts.RequestPermission()
28
+ ) { isGranted: Boolean ->
29
+ foregroundPromise?.let {
30
+ if (isGranted) {
31
+ it.resolve(true)
32
+ } else {
33
+ it.reject("Permission denied")
34
+ }
35
+ foregroundPromise = null
36
+ }
37
+ }
38
+
39
+ private val requestBackgroundPermissionLauncher =
40
+ (reactContext.currentActivity as? ComponentActivity)?.registerForActivityResult(
41
+ ActivityResultContracts.RequestPermission()
42
+ ) { isGranted: Boolean ->
43
+ backgroundPromise?.let {
44
+ if (isGranted) {
45
+ it.resolve(true)
46
+ } else {
47
+ it.reject("Permission denied")
48
+ }
49
+ backgroundPromise = null
50
+ }
51
+ }
52
+
53
+ @ReactMethod
54
+ fun requestForegroundPermissions(promise: Promise) {
55
+ val activity = currentActivity
56
+ if (activity == null) {
57
+ promise.reject("Activity doesn't exist")
58
+ return
59
+ }
60
+
61
+ if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
62
+ promise.resolve(true)
63
+ } else {
64
+ foregroundPromise = promise
65
+ requestForegroundPermissionLauncher?.launch(Manifest.permission.ACCESS_FINE_LOCATION)
66
+ }
67
+ }
68
+
69
+ @ReactMethod
70
+ fun requestBackgroundPermissions(promise: Promise) {
71
+ val activity = currentActivity
72
+ if (activity == null) {
73
+ promise.reject("Activity doesn't exist")
74
+ return
75
+ }
76
+
77
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
78
+ // For devices running Android versions below Q, background location permission is not needed.
79
+ promise.resolve(true)
80
+ return
81
+ }
82
+
83
+ if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED) {
84
+ promise.resolve(true)
85
+ } else {
86
+ backgroundPromise = promise
87
+ requestBackgroundPermissionLauncher?.launch(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
88
+ }
89
+ }
90
+ }
@@ -9,13 +9,25 @@
9
9
  import UIKit
10
10
 
11
11
  class EventEmitter{
12
+
12
13
  public static var sharedInstance = EventEmitter()
14
+
13
15
  private static var eventEmitter: RNEventEmitter!
16
+
14
17
  private init() {}
18
+
15
19
  func registerEventEmitter(eventEmitter: RNEventEmitter) {
16
20
  EventEmitter.eventEmitter = eventEmitter
17
21
  }
18
- func dispatch(name: String, body: [String:Any]?) {
22
+
23
+ func dispatch(name: String, body: Any?) {
19
24
  EventEmitter.eventEmitter.sendEvent(withName: name, body: body)
20
25
  }
26
+
27
+ /// All Events which must be support by React Native.
28
+ lazy var allEvents: [String] = {
29
+ var allEventNames: [String] = ["locationUpdated"]
30
+ return allEventNames
31
+ }()
32
+
21
33
  }
@@ -0,0 +1,143 @@
1
+ //
2
+ // LocationManager.swift
3
+ // MySDK
4
+ //
5
+ // Created by Apple on 21/02/23.
6
+ //
7
+
8
+ import Foundation
9
+ import CoreLocation
10
+
11
+
12
+ public class LocationManager: NSObject,CLLocationManagerDelegate {
13
+ private var locationManager: CLLocationManager?
14
+ private var permissionEnabled: Bool = false
15
+ var completePermisisonRequestBlock: ((Bool) -> Void)? = nil
16
+ var lastLocationData = [String: Double]()
17
+
18
+ struct Static
19
+ {
20
+ static var instance: LocationManager?
21
+ }
22
+ var startSyncBool:Bool = false
23
+
24
+ override init(){
25
+ super.init()
26
+ setupLocationManager()
27
+ }
28
+
29
+
30
+ public class var sharedInstance: LocationManager
31
+ {
32
+ if Static.instance == nil
33
+ {
34
+ Static.instance = LocationManager()
35
+ }
36
+ debugPrint("Yes I called inside shared instance")
37
+ return Static.instance!
38
+ }
39
+
40
+
41
+ private func setupLocationManager(){
42
+ if(self.locationManager == nil){
43
+ DispatchQueue.main.async {
44
+ self.lastLocationData["latitude"] = 0.0
45
+ self.lastLocationData["longitude"] = 0.0
46
+ self.lastLocationData["accuracy"] = 0.0
47
+ self.locationManager = CLLocationManager()
48
+ self.locationManager?.delegate = self
49
+ self.locationManager?.allowsBackgroundLocationUpdates = true
50
+ self.locationManager?.pausesLocationUpdatesAutomatically = false
51
+ self.locationManager?.desiredAccuracy = kCLLocationAccuracyBestForNavigation
52
+ self.locationManager?.distanceFilter = 10
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ public func getLastLocation()->[String:Double]{
59
+ return self.lastLocationData
60
+ }
61
+ public func locationPermissionEnabled() -> Bool{
62
+ return self.permissionEnabled
63
+ }
64
+
65
+ private func callPermissionCallBack(permissionStatus: Bool){
66
+ if let completionBlock = self.completePermisisonRequestBlock {
67
+ completionBlock(permissionStatus);
68
+ }
69
+ }
70
+ public func requestLocationPermissions(){
71
+ if CLLocationManager.locationServicesEnabled() {
72
+ let currentStatus = self.locationManager?.authorizationStatus
73
+ switch currentStatus {
74
+ case .notDetermined, .restricted, .denied:
75
+ self.permissionEnabled = false
76
+ self.callPermissionCallBack(permissionStatus: self.permissionEnabled)
77
+ self.completePermisisonRequestBlock = nil
78
+ break
79
+ case .authorizedWhenInUse, .authorizedAlways:
80
+ self.permissionEnabled = true
81
+ self.callPermissionCallBack(permissionStatus: self.permissionEnabled)
82
+ self.completePermisisonRequestBlock = nil
83
+ break
84
+ case .none:
85
+ self.permissionEnabled = false
86
+ self.locationManager?.requestWhenInUseAuthorization()
87
+ break
88
+ @unknown default:
89
+ debugPrint("restricted not")
90
+ }
91
+ } else {
92
+ self.permissionEnabled = false
93
+ self.callPermissionCallBack(permissionStatus: self.permissionEnabled)
94
+ self.completePermisisonRequestBlock = nil
95
+ }
96
+ }
97
+
98
+ public func startLocationUpdates(){
99
+ self.locationManager?.startUpdatingLocation()
100
+ }
101
+
102
+ public func stopLocationUpdates(){
103
+ self.locationManager?.stopUpdatingLocation()
104
+ }
105
+
106
+ private func sendEvent(locationData:[String:Double]){
107
+ // EventEmitter.sharedInstance.dispatch(name: "locationUpdated", body: locationData)
108
+ }
109
+
110
+ public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
111
+ debugPrint("locationManager:didUpdateLocations:\(locations)")
112
+ if let lastLocation = locations.last{
113
+ let coordinate: CLLocationCoordinate2D = lastLocation.coordinate
114
+ self.lastLocationData["latitude"] = coordinate.latitude
115
+ self.lastLocationData["longitude"] = coordinate.longitude
116
+ if(lastLocation.horizontalAccuracy > 0){
117
+ self.lastLocationData["accuracy"] = lastLocation.horizontalAccuracy
118
+ }else if(lastLocation.verticalAccuracy > 0){
119
+ self.lastLocationData["accuracy"] = lastLocation.verticalAccuracy
120
+ }
121
+ self.sendEvent(locationData: self.lastLocationData)
122
+ debugPrint("locationManager:didUpdateLocations:lastLocationData:\(self.lastLocationData)")
123
+ }
124
+ }
125
+
126
+ public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
127
+ debugPrint("locationManager:didFailWithError:\(error.localizedDescription)")
128
+ }
129
+
130
+ public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
131
+ if manager.authorizationStatus == .authorizedWhenInUse || manager.authorizationStatus == .authorizedAlways{
132
+ self.permissionEnabled = true
133
+ self.callPermissionCallBack(permissionStatus: self.permissionEnabled)
134
+ self.completePermisisonRequestBlock = nil
135
+ }else{
136
+ self.permissionEnabled = false
137
+ self.callPermissionCallBack(permissionStatus: self.permissionEnabled)
138
+ self.completePermisisonRequestBlock = nil
139
+ }
140
+ }
141
+
142
+ }
143
+
@@ -0,0 +1,19 @@
1
+ //
2
+ // LocationModule.m
3
+ // DispatchSdk
4
+ //
5
+ // Created by apple on 26/12/24.
6
+ // Copyright © 2024 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTBridgeModule.h>
10
+ #import <React/RCTEventEmitter.h>
11
+
12
+ @interface RCT_EXTERN_MODULE(LocationModule, RCTEventEmitter)
13
+
14
+ RCT_EXTERN_METHOD(startLocationUpdates:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
15
+ RCT_EXTERN_METHOD(stopLocationUpdates:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
16
+ RCT_EXTERN_METHOD(getLastLocation:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
17
+
18
+
19
+ @end
@@ -0,0 +1,32 @@
1
+
2
+ @objc(LocationModule)
3
+
4
+ class LocationModule: RNEventEmitter{
5
+
6
+ @objc(startLocationUpdates:withRejecter:)
7
+ func startLocationUpdates(resolve: RCTPromiseResolveBlock, withRejecter reject: RCTPromiseRejectBlock) -> Void {
8
+ LocationManager.sharedInstance.startLocationUpdates()
9
+ resolve(true)
10
+ }
11
+
12
+ @objc(stopLocationUpdates:withRejecter:)
13
+ func stopLocationUpdates(resolve: RCTPromiseResolveBlock, withRejecter reject: RCTPromiseRejectBlock) -> Void {
14
+ LocationManager.sharedInstance.stopLocationUpdates()
15
+ resolve(true)
16
+ }
17
+
18
+ @objc(getLastLocation:withRejecter:)
19
+ func getLastLocation(resolve: RCTPromiseResolveBlock, withRejecter reject: RCTPromiseRejectBlock) -> Void {
20
+ let location = LocationManager.sharedInstance.getLastLocation()
21
+ resolve(location)
22
+ }
23
+
24
+ /// Explicitly override supportedEvents to satisfy RCTEventEmitter requirements
25
+ @objc override func supportedEvents() -> [String] {
26
+ return super.supportedEvents() // Delegate to RNEventEmitter
27
+ }
28
+ }
29
+
30
+
31
+
32
+
@@ -0,0 +1,21 @@
1
+ //
2
+ // PermissionModule.m
3
+ // DispatchSdk
4
+ //
5
+ // Created by apple on 26/12/24.
6
+ // Copyright © 2024 Facebook. All rights reserved.
7
+ //
8
+ #import <React/RCTBridgeModule.h>
9
+ #import <React/RCTEventEmitter.h>
10
+
11
+ @interface RCT_EXTERN_MODULE(PermissionsModule, NSObject)
12
+
13
+ RCT_EXTERN_METHOD(requestForegroundPermissions:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
14
+ RCT_EXTERN_METHOD(requestBackgroundPermissions:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
15
+
16
+ + (BOOL)requiresMainQueueSetup
17
+ {
18
+ return NO;
19
+ }
20
+
21
+ @end
@@ -0,0 +1,24 @@
1
+
2
+ import CoreLocation
3
+ @objc(PermissionsModule)
4
+ class PermissionsModule: NSObject{
5
+
6
+ @objc(requestForegroundPermissions:withRejecter:)
7
+ func requestForegroundPermissions(resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
8
+ LocationManager.sharedInstance.completePermisisonRequestBlock = { (response) -> Void in
9
+ resolve(response)
10
+ }
11
+ LocationManager.sharedInstance.requestLocationPermissions();
12
+ }
13
+ @objc(requestBackgroundPermissions:withRejecter:)
14
+ func requestBackgroundPermissions(resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
15
+ LocationManager.sharedInstance.completePermisisonRequestBlock = { (response) -> Void in
16
+ resolve(response)
17
+ }
18
+ LocationManager.sharedInstance.requestLocationPermissions();
19
+ }
20
+ }
21
+
22
+
23
+
24
+
@@ -1,15 +1,9 @@
1
- //
2
- // RNEventEmitter.m
3
- // TiresKicked
4
- //
5
- // Created by Apple on 07/11/22.
6
- // Copyright © 2022 Facebook. All rights reserved.
7
- //
8
-
9
1
  #import <Foundation/Foundation.h>
10
2
  #import <React/RCTBridgeModule.h>
11
3
  #import <React/RCTEventEmitter.h>
12
4
 
13
5
  @interface RCT_EXTERN_MODULE(RNEventEmitter, RCTEventEmitter)
14
6
 
7
+ RCT_EXTERN_METHOD(supportedEvents)
8
+
15
9
  @end
@@ -1,24 +1,18 @@
1
- //
2
- // RNEventEmitter.swift
3
- // TiresKicked
4
- //
5
- // Created by Apple on 07/11/22.
6
- // Copyright © 2022 Facebook. All rights reserved.
7
- //
8
-
9
1
  import Foundation
10
- import React
2
+
11
3
  @objc(RNEventEmitter)
12
4
  open class RNEventEmitter: RCTEventEmitter {
13
- override init() {
14
- super.init()
15
- EventEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
16
- }
17
- open override func supportedEvents() -> [String]! {
18
- return [EventsConstant.START.rawValue]
19
- }
20
5
 
21
- public override static func requiresMainQueueSetup() -> Bool { return false
22
-
23
- }
6
+ override init() {
7
+ super.init()
8
+ EventEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
9
+ }
10
+
11
+ /// Base overide for RCTEventEmitter.
12
+ ///
13
+ /// - Returns: all supported events
14
+ @objc open override func supportedEvents() -> [String] {
15
+ return EventEmitter.sharedInstance.allEvents
16
+ }
17
+
24
18
  }
@@ -116,9 +116,11 @@ const SignatureET = props => {
116
116
  const folderName = (await _DispatchSdkCache.default.getInstance().getKeyFromCache(_DispatchSdkCache.default.KEYS.FMS_FOLDER)) ?? 'NULL';
117
117
  const dateTime = await _callbacksHandler.default.getDateTime();
118
118
  console.log('saveAndSubmit:dateTime: ', dateTime);
119
- let lat = _LocationManager.default.getInstance().getLastLocation().latitude;
120
- let lng = _LocationManager.default.getInstance().getLastLocation().longitude;
121
- let accuracy = _LocationManager.default.getInstance().getLastLocation().accuracy;
119
+ let lastLocation = await _LocationManager.default.getInstance().getLastLocation();
120
+ console.log("signatureET:lastLocation:", JSON.stringify(lastLocation));
121
+ let lat = lastLocation.latitude;
122
+ let lng = lastLocation.longitude;
123
+ let accuracy = lastLocation.accuracy;
122
124
  let insertID = await (0, _SyncManagerUtils.insertDocumentInDB)(fileName, folderName,
123
125
  // JSON.stringify(props.jobIDs),
124
126
  // JSON.stringify(props.objRefs),