react-native-bg-geolocation 0.2.0

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 (142) hide show
  1. package/BgGeolocation.podspec +39 -0
  2. package/LICENSE +20 -0
  3. package/README.md +366 -0
  4. package/android/build.gradle +69 -0
  5. package/android/src/main/AndroidManifest.xml +53 -0
  6. package/android/src/main/java/com/bggeolocation/BgGeolocationActivityRecognitionReceiver.kt +116 -0
  7. package/android/src/main/java/com/bggeolocation/BgGeolocationBootReceiver.kt +44 -0
  8. package/android/src/main/java/com/bggeolocation/BgGeolocationForegroundService.kt +373 -0
  9. package/android/src/main/java/com/bggeolocation/BgGeolocationGeofenceReceiver.kt +55 -0
  10. package/android/src/main/java/com/bggeolocation/BgGeolocationHeadlessTask.kt +138 -0
  11. package/android/src/main/java/com/bggeolocation/BgGeolocationModule.kt +1030 -0
  12. package/android/src/main/java/com/bggeolocation/BgGeolocationMotionStateMachine.kt +159 -0
  13. package/android/src/main/java/com/bggeolocation/BgGeolocationPackage.kt +31 -0
  14. package/android/src/main/res/drawable/bg_geo_notification.xml +9 -0
  15. package/ios/BgGeolocation.h +14 -0
  16. package/ios/BgGeolocation.mm +709 -0
  17. package/ios/engine/AtomicBoolean.swift +48 -0
  18. package/ios/engine/BGActivityChangeEvent.swift +20 -0
  19. package/ios/engine/BGActivityConfig.swift +71 -0
  20. package/ios/engine/BGAppConfig.swift +92 -0
  21. package/ios/engine/BGAppState.swift +147 -0
  22. package/ios/engine/BGAuthorization.swift +85 -0
  23. package/ios/engine/BGAuthorizationAlertPresenter.swift +39 -0
  24. package/ios/engine/BGAuthorizationConfig.swift +50 -0
  25. package/ios/engine/BGAuthorizationEvent.swift +40 -0
  26. package/ios/engine/BGBackgroundTaskManager.swift +143 -0
  27. package/ios/engine/BGCLRouter.swift +101 -0
  28. package/ios/engine/BGCallback.swift +19 -0
  29. package/ios/engine/BGConfig.swift +440 -0
  30. package/ios/engine/BGConfigModuleBase.swift +180 -0
  31. package/ios/engine/BGConfigOLD.swift +582 -0
  32. package/ios/engine/BGConnectivityChangeEvent.swift +15 -0
  33. package/ios/engine/BGCrashDetector.swift +122 -0
  34. package/ios/engine/BGCurrentPositionRequest.swift +87 -0
  35. package/ios/engine/BGDataStore.swift +75 -0
  36. package/ios/engine/BGDatabase.swift +677 -0
  37. package/ios/engine/BGDatabasePool.swift +220 -0
  38. package/ios/engine/BGDatabaseQueue.swift +215 -0
  39. package/ios/engine/BGDateUtils.swift +26 -0
  40. package/ios/engine/BGDeviceInfo.swift +54 -0
  41. package/ios/engine/BGDeviceManager.swift +65 -0
  42. package/ios/engine/BGEnabledChangeEvent.swift +11 -0
  43. package/ios/engine/BGEnv.swift +17 -0
  44. package/ios/engine/BGEventBus.swift +83 -0
  45. package/ios/engine/BGEventManager.swift +169 -0
  46. package/ios/engine/BGEventNames.swift +51 -0
  47. package/ios/engine/BGGeofence.swift +233 -0
  48. package/ios/engine/BGGeofenceDAO.swift +152 -0
  49. package/ios/engine/BGGeofenceEvent.swift +42 -0
  50. package/ios/engine/BGGeofenceLocationRequest.swift +94 -0
  51. package/ios/engine/BGGeofenceManager.swift +315 -0
  52. package/ios/engine/BGGeofenceTransition.swift +97 -0
  53. package/ios/engine/BGGeofencesChangeEvent.swift +26 -0
  54. package/ios/engine/BGGeolocationConfig.swift +136 -0
  55. package/ios/engine/BGHeartbeatEvent.swift +31 -0
  56. package/ios/engine/BGHeartbeatService.swift +51 -0
  57. package/ios/engine/BGHttpConfig.swift +105 -0
  58. package/ios/engine/BGHttpErrorCodes.swift +63 -0
  59. package/ios/engine/BGHttpEvent.swift +34 -0
  60. package/ios/engine/BGHttpRequest.swift +126 -0
  61. package/ios/engine/BGHttpResponse.swift +93 -0
  62. package/ios/engine/BGHttpService.swift +428 -0
  63. package/ios/engine/BGKalmanFilter.swift +105 -0
  64. package/ios/engine/BGLMActionNames.swift +55 -0
  65. package/ios/engine/BGLicenseManager.swift +26 -0
  66. package/ios/engine/BGLiveActivityManager.swift +327 -0
  67. package/ios/engine/BGLocation.swift +311 -0
  68. package/ios/engine/BGLocationAuthorization.swift +427 -0
  69. package/ios/engine/BGLocationDAO.swift +252 -0
  70. package/ios/engine/BGLocationErrors.swift +28 -0
  71. package/ios/engine/BGLocationEvent.swift +43 -0
  72. package/ios/engine/BGLocationFilter.swift +82 -0
  73. package/ios/engine/BGLocationFilterConfig.swift +57 -0
  74. package/ios/engine/BGLocationHelper.swift +54 -0
  75. package/ios/engine/BGLocationManager.swift +662 -0
  76. package/ios/engine/BGLocationMetricsEngine.swift +116 -0
  77. package/ios/engine/BGLocationRequestService.swift +459 -0
  78. package/ios/engine/BGLocationSatisfier.swift +14 -0
  79. package/ios/engine/BGLocationStreamEvent.swift +27 -0
  80. package/ios/engine/BGLog.swift +337 -0
  81. package/ios/engine/BGLogLevel.swift +26 -0
  82. package/ios/engine/BGLoggerConfig.swift +60 -0
  83. package/ios/engine/BGMotionActivity.swift +31 -0
  84. package/ios/engine/BGMotionActivityClassifier.swift +108 -0
  85. package/ios/engine/BGMotionActivityManagerAdapter.swift +40 -0
  86. package/ios/engine/BGMotionActivitySource.swift +46 -0
  87. package/ios/engine/BGMotionDetector.swift +377 -0
  88. package/ios/engine/BGMotionPermissionManager.swift +50 -0
  89. package/ios/engine/BGNativeLogger.swift +48 -0
  90. package/ios/engine/BGNotificaitons.swift +37 -0
  91. package/ios/engine/BGOdometer.swift +66 -0
  92. package/ios/engine/BGPersistenceConfig.swift +29 -0
  93. package/ios/engine/BGPolygonStreamRequest.swift +48 -0
  94. package/ios/engine/BGPowerSaveChangeEvent.swift +12 -0
  95. package/ios/engine/BGPropertySpec.swift +29 -0
  96. package/ios/engine/BGProviderChangeEvent.swift +31 -0
  97. package/ios/engine/BGQueue.swift +50 -0
  98. package/ios/engine/BGRPC.swift +194 -0
  99. package/ios/engine/BGReachability.swift +58 -0
  100. package/ios/engine/BGResultSet.swift +157 -0
  101. package/ios/engine/BGSchedule.swift +228 -0
  102. package/ios/engine/BGScheduleEvent.swift +13 -0
  103. package/ios/engine/BGScheduler.swift +116 -0
  104. package/ios/engine/BGSingleLocationRequest.swift +49 -0
  105. package/ios/engine/BGStreamLocationRequest.swift +42 -0
  106. package/ios/engine/BGTemplate.swift +54 -0
  107. package/ios/engine/BGTimerService.swift +46 -0
  108. package/ios/engine/BGTrackingAudioManager.swift +286 -0
  109. package/ios/engine/BGTrackingService.swift +879 -0
  110. package/ios/engine/BGWatchPositionRequest.swift +63 -0
  111. package/ios/engine/DatabaseQueue.swift +47 -0
  112. package/ios/engine/LogQuery.swift +10 -0
  113. package/ios/engine/SQLQuery.swift +65 -0
  114. package/ios/engine/TransistorAuthorizationToken.swift +182 -0
  115. package/ios/liveactivity/BGLiveTrackingAttributes.swift +52 -0
  116. package/ios/locationpush/BGLocationPushDeliverer.swift +260 -0
  117. package/ios/locationpush/BGLocationPushService.swift +161 -0
  118. package/ios/locationpush/BGLocationPushShared.swift +98 -0
  119. package/ios/locationpush/BGLocationPushSocketClient.swift +198 -0
  120. package/lib/module/NativeBgGeolocation.js +5 -0
  121. package/lib/module/NativeBgGeolocation.js.map +1 -0
  122. package/lib/module/events.js +20 -0
  123. package/lib/module/events.js.map +1 -0
  124. package/lib/module/index.js +706 -0
  125. package/lib/module/index.js.map +1 -0
  126. package/lib/module/package.json +1 -0
  127. package/lib/module/types.js +2 -0
  128. package/lib/module/types.js.map +1 -0
  129. package/lib/typescript/package.json +1 -0
  130. package/lib/typescript/src/NativeBgGeolocation.d.ts +57 -0
  131. package/lib/typescript/src/NativeBgGeolocation.d.ts.map +1 -0
  132. package/lib/typescript/src/events.d.ts +18 -0
  133. package/lib/typescript/src/events.d.ts.map +1 -0
  134. package/lib/typescript/src/index.d.ts +238 -0
  135. package/lib/typescript/src/index.d.ts.map +1 -0
  136. package/lib/typescript/src/types.d.ts +229 -0
  137. package/lib/typescript/src/types.d.ts.map +1 -0
  138. package/package.json +141 -0
  139. package/src/NativeBgGeolocation.ts +236 -0
  140. package/src/events.ts +17 -0
  141. package/src/index.tsx +935 -0
  142. package/src/types.ts +254 -0
@@ -0,0 +1,180 @@
1
+ import Foundation
2
+
3
+ @objc public class BGPropertySpecImpl: NSObject {
4
+ @objc public let name: String
5
+ @objc public let type: String
6
+ @objc public init(name: String, type: String) {
7
+ self.name = name
8
+ self.type = type
9
+ super.init()
10
+ }
11
+ }
12
+
13
+ public func BGPropertySpec(name: String, type: String) -> BGPropertySpecImpl {
14
+ return BGPropertySpecImpl(name: name, type: type)
15
+ }
16
+
17
+ @objc public class BGConfigModuleBase: NSObject {
18
+
19
+ @objc public var trackExplicitKeys: Bool = false
20
+ private var explicitKeys: Set<String> = []
21
+ private var changeObservers: [String: [AnyObject]] = [:]
22
+
23
+ @objc public override class func automaticallyNotifiesObservers(forKey key: String) -> Bool {
24
+ return false
25
+ }
26
+
27
+ @objc public override init() {
28
+ super.init()
29
+ applyDefaults()
30
+ }
31
+
32
+ @objc public func applyDefaults() {}
33
+
34
+ @objc public func propertySpecs() -> [BGPropertySpecImpl] { return [] }
35
+
36
+ @objc public func allPropertyNames() -> [String] {
37
+ return propertySpecs().map { $0.name }
38
+ }
39
+
40
+ @objc public func hasProperty(_ name: String) -> Bool {
41
+ return allPropertyNames().contains(name)
42
+ }
43
+
44
+ @objc public func canHandleProperty(_ name: String) -> Bool {
45
+ return hasProperty(name)
46
+ }
47
+
48
+ @objc public func sensitivePropertyNames() -> [String] {
49
+ return []
50
+ }
51
+
52
+ @objc public func deprecatedPropertyMappings() -> [String: String] {
53
+ return [:]
54
+ }
55
+
56
+ @objc public func currentPropertyName(forDeprecated deprecated: String) -> String? {
57
+ return deprecatedPropertyMappings()[deprecated]
58
+ }
59
+
60
+ @objc public func markExplicitKey(_ key: String) {
61
+ explicitKeys.insert(key)
62
+ }
63
+
64
+ @objc public func clearExplicitKeys() {
65
+ explicitKeys.removeAll()
66
+ }
67
+
68
+ @objc public func wasExplicitlySet(_ key: String) -> Bool {
69
+ return explicitKeys.contains(key)
70
+ }
71
+
72
+ @objc public func userConfigured() -> [String: Any] {
73
+ var result: [String: Any] = [:]
74
+ for key in explicitKeys {
75
+ if let val = value(forKey: key) {
76
+ result[key] = val
77
+ }
78
+ }
79
+ return result
80
+ }
81
+
82
+ @objc public func updateWithDictionary(_ dict: [String: Any]) {
83
+ for (key, value) in dict {
84
+ let targetKey = currentPropertyName(forDeprecated: key) ?? key
85
+ if canHandleProperty(targetKey) {
86
+ setValue(value, forProperty: targetKey)
87
+ if trackExplicitKeys { markExplicitKey(targetKey) }
88
+ }
89
+ }
90
+ }
91
+
92
+ @objc public func setValue(_ value: Any?, forProperty key: String) {
93
+ let coerced = defaultCoerce(value, forKey: key)
94
+ let old = self.value(forKey: key)
95
+ willChangeValue(forKey: key)
96
+ primitiveWriteValue(coerced, forKey: key)
97
+ didChangeValue(forKey: key)
98
+ propertyDidChange(key, oldValue: old, newValue: coerced)
99
+ }
100
+
101
+ @objc public override func setValue(_ value: Any?, forKey key: String) {
102
+ if canHandleProperty(key) {
103
+ setValue(value, forProperty: key)
104
+ } else {
105
+ super.setValue(value, forKey: key)
106
+ }
107
+ }
108
+
109
+ @objc public override func setValue(_ value: Any?, forUndefinedKey key: String) {
110
+ }
111
+
112
+ @objc public func primitiveWriteValue(_ value: Any?, forKey key: String) {
113
+ super.setValue(value, forKey: key)
114
+ }
115
+
116
+ @objc public func defaultCoerce(_ value: Any?, forKey key: String) -> Any? {
117
+ return value
118
+ }
119
+
120
+ @objc public func valueForProperty(_ key: String) -> Any? {
121
+ return value(forKey: key)
122
+ }
123
+
124
+ @objc public func validateValue(_ value: Any?, forKey key: String) -> Bool {
125
+ return true
126
+ }
127
+
128
+ @objc public func isValue(_ a: Any?, equalTo b: Any?) -> Bool {
129
+ if let a = a as? NSObject, let b = b as? NSObject {
130
+ return a.isEqual(b)
131
+ }
132
+ return a == nil && b == nil
133
+ }
134
+
135
+ @objc public func applyAndDiff(_ dict: [String: Any]) -> [String] {
136
+ var changed: [String] = []
137
+ for (key, newValue) in dict {
138
+ let targetKey = currentPropertyName(forDeprecated: key) ?? key
139
+ guard canHandleProperty(targetKey) else { continue }
140
+ let old = value(forKey: targetKey)
141
+ setValue(newValue, forProperty: targetKey)
142
+ if !isValue(old, equalTo: newValue) {
143
+ changed.append(targetKey)
144
+ }
145
+ }
146
+ return changed
147
+ }
148
+
149
+ @objc public func resetPropertyToDefault(_ key: String) {
150
+ applyDefaults()
151
+ }
152
+
153
+ @objc public func propertyDidChange(_ key: String, oldValue: Any?, newValue: Any?) {}
154
+
155
+ @objc public func contributeDeprecatedProperties(_ dict: NSMutableDictionary, redact: Bool) {}
156
+
157
+ @objc public func redactedValue(forProperty name: String, originalValue: Any?) -> Any? {
158
+ if sensitivePropertyNames().contains(name) { return "**redacted**" }
159
+ return originalValue
160
+ }
161
+
162
+ @objc public func toDictionary() -> [String: Any] {
163
+ return toDictionary(false)
164
+ }
165
+
166
+ @objc public func toDictionary(_ redact: Bool) -> [String: Any] {
167
+ var dict: [String: Any] = [:]
168
+ for spec in propertySpecs() {
169
+ let val = value(forKey: spec.name)
170
+ dict[spec.name] = redact ? redactedValue(forProperty: spec.name, originalValue: val) : val
171
+ }
172
+ return dict
173
+ }
174
+
175
+ @objc public func validateConfiguration() -> Bool { return true }
176
+
177
+ @objc public override var description: String {
178
+ return "<\(type(of: self)) \(toDictionary())>"
179
+ }
180
+ }