@log-drop/react-native 2.0.3 → 2.0.4

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.
@@ -12,9 +12,6 @@ RCT_EXTERN_METHOD(sendLogs)
12
12
  RCT_EXTERN_METHOD(saveCustomCrashReport:(NSString *)threadName
13
13
  stackTrace:(NSString *)stackTrace
14
14
  crashType:(NSString *)crashType)
15
- RCT_EXTERN_METHOD(requestDemoPermission:(NSString *)permission
16
- resolver:(RCTPromiseResolveBlock)resolve
17
- rejecter:(RCTPromiseRejectBlock)reject)
18
15
 
19
16
  + (BOOL)requiresMainQueueSetup
20
17
  {
@@ -1,21 +1,8 @@
1
- import AVFoundation
2
- import Contacts
3
- import CoreLocation
4
- import EventKit
5
1
  import LogDropSDK
6
- import Photos
7
2
  import React
8
- import UserNotifications
9
3
 
10
4
  @objc(LogDropReactNative)
11
- class LogDropReactNative: NSObject, CLLocationManagerDelegate {
12
- private let locationManager = CLLocationManager()
13
- private var pendingLocationResolver: RCTPromiseResolveBlock?
14
-
15
- override init() {
16
- super.init()
17
- locationManager.delegate = self
18
- }
5
+ class LogDropReactNative: NSObject {
19
6
 
20
7
  @objc
21
8
  func initLogDrop(_ config: NSDictionary) {
@@ -69,7 +56,6 @@ class LogDropReactNative: NSObject, CLLocationManagerDelegate {
69
56
  LogDrop.e(message, logFlow: parsedFlow, file: tag)
70
57
  }
71
58
 
72
-
73
59
  @objc
74
60
  func userUpdate(_ userUuid: String) {
75
61
  LogDrop.updateUser(userUuid: userUuid)
@@ -86,175 +72,4 @@ class LogDropReactNative: NSObject, CLLocationManagerDelegate {
86
72
  stackTrace: stackTrace,
87
73
  crashType: crashType)
88
74
  }
89
-
90
- @objc
91
- func requestDemoPermission(
92
- _ permission: String,
93
- resolver resolve: @escaping RCTPromiseResolveBlock,
94
- rejecter reject: @escaping RCTPromiseRejectBlock
95
- ) {
96
- DispatchQueue.main.async {
97
- switch permission {
98
- case "notifications":
99
- UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { _, _ in
100
- UNUserNotificationCenter.current().getNotificationSettings { settings in
101
- resolve(Self.notificationStatus(settings.authorizationStatus))
102
- }
103
- }
104
- case "location":
105
- self.pendingLocationResolver = resolve
106
- self.locationManager.requestWhenInUseAuthorization()
107
- case "camera":
108
- AVCaptureDevice.requestAccess(for: .video) { _ in
109
- resolve(Self.videoStatus(AVCaptureDevice.authorizationStatus(for: .video)))
110
- }
111
- case "microphone":
112
- AVAudioSession.sharedInstance().requestRecordPermission { _ in
113
- resolve(Self.audioStatus(AVAudioSession.sharedInstance().recordPermission))
114
- }
115
- case "contacts":
116
- CNContactStore().requestAccess(for: .contacts) { _, _ in
117
- resolve(Self.contactsStatus(CNContactStore.authorizationStatus(for: .contacts)))
118
- }
119
- case "calendar":
120
- let store = EKEventStore()
121
- if #available(iOS 17.0, *) {
122
- store.requestFullAccessToEvents { _, _ in
123
- resolve(Self.calendarStatus(EKEventStore.authorizationStatus(for: .event)))
124
- }
125
- } else {
126
- store.requestAccess(to: .event) { _, _ in
127
- resolve(Self.calendarStatus(EKEventStore.authorizationStatus(for: .event)))
128
- }
129
- }
130
- case "photos":
131
- PHPhotoLibrary.requestAuthorization(for: .readWrite) { _ in
132
- resolve(Self.photoStatus(PHPhotoLibrary.authorizationStatus(for: .readWrite)))
133
- }
134
- default:
135
- reject("unsupported_permission", "Unsupported demo permission: \(permission)", nil)
136
- }
137
- }
138
- }
139
-
140
- func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
141
- pendingLocationResolver?(Self.locationStatus(CLLocationManager.authorizationStatus()))
142
- pendingLocationResolver = nil
143
- }
144
-
145
- private static func notificationStatus(_ status: UNAuthorizationStatus) -> String {
146
- switch status {
147
- case .authorized, .provisional, .ephemeral:
148
- return "granted"
149
- case .denied:
150
- return "denied"
151
- case .notDetermined:
152
- return "not_determined"
153
- @unknown default:
154
- return "restricted"
155
- }
156
- }
157
-
158
- private static func locationStatus(_ status: CLAuthorizationStatus) -> String {
159
- switch status {
160
- case .authorizedAlways, .authorizedWhenInUse:
161
- return "granted"
162
- case .denied:
163
- return "denied"
164
- case .notDetermined:
165
- return "not_determined"
166
- case .restricted:
167
- return "restricted"
168
- @unknown default:
169
- return "restricted"
170
- }
171
- }
172
-
173
- private static func videoStatus(_ status: AVAuthorizationStatus) -> String {
174
- switch status {
175
- case .authorized:
176
- return "granted"
177
- case .denied:
178
- return "denied"
179
- case .notDetermined:
180
- return "not_determined"
181
- case .restricted:
182
- return "restricted"
183
- @unknown default:
184
- return "restricted"
185
- }
186
- }
187
-
188
- private static func audioStatus(_ status: AVAudioSession.RecordPermission) -> String {
189
- switch status {
190
- case .granted:
191
- return "granted"
192
- case .denied:
193
- return "denied"
194
- case .undetermined:
195
- return "not_determined"
196
- @unknown default:
197
- return "restricted"
198
- }
199
- }
200
-
201
- private static func contactsStatus(_ status: CNAuthorizationStatus) -> String {
202
- switch status {
203
- case .authorized:
204
- return "granted"
205
- case .denied:
206
- return "denied"
207
- case .notDetermined:
208
- return "not_determined"
209
- case .restricted:
210
- return "restricted"
211
- @unknown default:
212
- return "restricted"
213
- }
214
- }
215
-
216
- private static func calendarStatus(_ status: EKAuthorizationStatus) -> String {
217
- if #available(iOS 17.0, *) {
218
- switch status {
219
- case .fullAccess, .writeOnly:
220
- return "granted"
221
- case .denied:
222
- return "denied"
223
- case .notDetermined:
224
- return "not_determined"
225
- case .restricted:
226
- return "restricted"
227
- @unknown default:
228
- return "restricted"
229
- }
230
- }
231
-
232
- switch status {
233
- case .authorized:
234
- return "granted"
235
- case .denied:
236
- return "denied"
237
- case .notDetermined:
238
- return "not_determined"
239
- case .restricted:
240
- return "restricted"
241
- @unknown default:
242
- return "restricted"
243
- }
244
- }
245
-
246
- private static func photoStatus(_ status: PHAuthorizationStatus) -> String {
247
- switch status {
248
- case .authorized, .limited:
249
- return "granted"
250
- case .denied:
251
- return "denied"
252
- case .notDetermined:
253
- return "not_determined"
254
- case .restricted:
255
- return "restricted"
256
- @unknown default:
257
- return "restricted"
258
- }
259
- }
260
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@log-drop/react-native",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "LogDrop React Native SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",