react-native-mytatva-rn-sdk 1.2.68 → 1.2.69

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.
@@ -139,23 +139,38 @@ class API {
139
139
  request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
140
140
  request.httpBody = encrypted.data(using: .utf8)
141
141
  print("===>url:", urlString)
142
- let (data, response) = try await URLSession.shared.data(for: request)
143
142
 
144
- if let httpResponse = response as? HTTPURLResponse {
145
- print("HTTP Status: \(httpResponse.statusCode)")
146
- }
143
+ // Use regular URLSession for foreground/background compatibility
144
+ // Background URLSession requires delegates, not completion handlers
145
+ let session = URLSession.shared
147
146
 
148
- if let responseStr = String(data: data, encoding: .utf8) {
149
- print("===>Server Response: \(responseStr)")
150
- if let decrypted = Crypto.shared.getDecryptedData(cipherText: responseStr, encryptionKey: encryptionKey, encryptionIv: encryptionIv) {
151
- print("===>Decrypted post cgm data response (for verification): \(decrypted)")
147
+ let task = session.uploadTask(with: request, from: encrypted.data(using: .utf8)) { data, response, error in
148
+ if let error = error {
149
+ print("===>Upload failed: \(error.localizedDescription)")
150
+ DispatchQueue.main.async {
151
+ onFailure(error)
152
+ }
153
+ return
154
+ }
155
+
156
+ if let httpResponse = response as? HTTPURLResponse {
157
+ print("HTTP Status: \(httpResponse.statusCode)")
158
+ }
159
+
160
+ if let data = data, let responseStr = String(data: data, encoding: .utf8) {
161
+ print("===>Server Response: \(responseStr)")
162
+ if let decrypted = Crypto.shared.getDecryptedData(cipherText: responseStr, encryptionKey: encryptionKey, encryptionIv: encryptionIv) {
163
+ print("===>Decrypted post cgm data response (for verification): \(decrypted)")
164
+ }
152
165
  }
153
166
 
167
+ DispatchQueue.main.async {
168
+ onSuccess()
169
+ }
154
170
  }
155
171
 
156
- DispatchQueue.main.async {
157
- onSuccess()
158
- }
172
+ task.resume()
173
+ print("===>Upload task started")
159
174
 
160
175
  } catch {
161
176
  print("===>Request failed: \(error.localizedDescription)")
@@ -216,8 +231,10 @@ class API {
216
231
 
217
232
  request.httpBody = encrypted.data(using: .utf8)
218
233
 
219
- // Perform request
220
- let task = URLSession.shared.dataTask(with: request) { data, response, error in
234
+ // Use regular URLSession for foreground/background compatibility
235
+ let session = URLSession.shared
236
+
237
+ let task = session.uploadTask(with: request, from: encrypted.data(using: .utf8)) { data, response, error in
221
238
  if let error = error {
222
239
  print("Error: \(error)")
223
240
  return
@@ -234,6 +251,7 @@ class API {
234
251
  }
235
252
  }
236
253
  task.resume()
254
+ print("===>Status upload started")
237
255
  }
238
256
 
239
257
  /*func getStatus(encryptionKey: String = PROD_ENC_KEY,
@@ -252,8 +252,10 @@ class FinalViewModel: NSObject {
252
252
 
253
253
  // Set request body
254
254
 
255
- // Perform request
256
- let task = URLSession.shared.dataTask(with: request) { data, response, error in
255
+ // Use regular URLSession for foreground/background compatibility
256
+ let session = URLSession.shared
257
+
258
+ let task = session.dataTask(with: request) { data, response, error in
257
259
  if let error = error {
258
260
  print("Error: \(error)")
259
261
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.68",
3
+ "version": "1.2.69",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",