@capgo/capacitor-updater 4.17.35 → 4.17.37

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.
@@ -66,16 +66,16 @@ extension GetChannel {
66
66
  }
67
67
  struct InfoObject: Codable {
68
68
  let platform: String?
69
- let device_id: String?
70
- let app_id: String?
71
- let custom_id: String?
72
- let version_build: String?
73
- let version_code: String?
74
- let version_os: String?
75
- let version_name: String?
76
- let plugin_version: String?
77
- let is_emulator: Bool?
78
- let is_prod: Bool?
69
+ let deviceId: String?
70
+ let appId: String?
71
+ let customId: String?
72
+ let versionBuild: String?
73
+ let versionCode: String?
74
+ let versionOS: String?
75
+ let versionName: String?
76
+ let pluginVersion: String?
77
+ let isEmulator: Bool?
78
+ let isProd: Bool?
79
79
  var action: String?
80
80
  var channel: String?
81
81
  }
@@ -85,7 +85,7 @@ struct AppVersionDec: Decodable {
85
85
  let url: String?
86
86
  let message: String?
87
87
  let error: String?
88
- let session_key: String?
88
+ let sessionKey: String?
89
89
  let major: Bool?
90
90
  }
91
91
  public class AppVersion: NSObject {
@@ -171,6 +171,7 @@ enum CustomError: Error {
171
171
 
172
172
  extension CustomError: LocalizedError {
173
173
  public var errorDescription: String? {
174
+ let invalidFolder: String = "Invalid folder"
174
175
  switch self {
175
176
  case .cannotUnzip:
176
177
  return NSLocalizedString(
@@ -180,17 +181,17 @@ extension CustomError: LocalizedError {
180
181
  case .cannotCreateDirectory:
181
182
  return NSLocalizedString(
182
183
  "The folder cannot be created",
183
- comment: "Invalid folder"
184
+ comment: invalidFolder
184
185
  )
185
186
  case .cannotDeleteDirectory:
186
187
  return NSLocalizedString(
187
188
  "The folder cannot be deleted",
188
- comment: "Invalid folder"
189
+ comment: invalidFolder
189
190
  )
190
191
  case .cannotUnflat:
191
192
  return NSLocalizedString(
192
193
  "The file cannot be unflat",
193
- comment: "Invalid folder"
194
+ comment: invalidFolder
194
195
  )
195
196
  case .unexpected:
196
197
  return NSLocalizedString(
@@ -219,22 +220,23 @@ extension CustomError: LocalizedError {
219
220
  private let documentsDir: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
220
221
  private let libraryDir: URL = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
221
222
  private let bundleDirectoryHot: String = "versions"
222
- private let DEFAULT_FOLDER: String = ""
223
+ private let defaultFolder: String = ""
223
224
  private let bundleDirectory: String = "NoCloud/ionic_built_snapshots"
224
- private let INFO_SUFFIX: String = "_info"
225
- private let FALLBACK_VERSION: String = "pastVersion"
226
- private let NEXT_VERSION: String = "nextVersion"
225
+ private let infoSuffix: String = "_info"
226
+ private let fallbackVersion: String = "pastVersion"
227
+ private let nextVersion: String = "nextVersion"
227
228
 
228
- public let TAG: String = "✨ Capacitor-updater:"
229
- public let CAP_SERVER_PATH: String = "serverBasePath"
229
+ public let tag: String = "✨ Capacitor-updater:"
230
+ public let capServerPath: String = "serverBasePath"
230
231
  public var customId: String = ""
231
- public var PLUGIN_VERSION: String = ""
232
+ public var pluginVersion: String = ""
232
233
  public let timeout: Double = 20
233
234
  public var statsUrl: String = ""
234
235
  public var channelUrl: String = ""
235
236
  public var appId: String = ""
236
237
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
237
238
  public var privateKey: String = ""
239
+ private let indexHTML: String = "index.html"
238
240
 
239
241
  public var notifyDownload: (String, Int) -> Void = { _, _ in }
240
242
 
@@ -290,7 +292,7 @@ extension CustomError: LocalizedError {
290
292
  do {
291
293
  try FileManager.default.createDirectory(atPath: source.path, withIntermediateDirectories: true, attributes: nil)
292
294
  } catch {
293
- print("\(self.TAG) Cannot createDirectory \(source.path)")
295
+ print("\(self.tag) Cannot createDirectory \(source.path)")
294
296
  throw CustomError.cannotCreateDirectory
295
297
  }
296
298
  }
@@ -300,13 +302,13 @@ extension CustomError: LocalizedError {
300
302
  do {
301
303
  try FileManager.default.removeItem(atPath: source.path)
302
304
  } catch {
303
- print("\(self.TAG) File not removed. \(source.path)")
305
+ print("\(self.tag) File not removed. \(source.path)")
304
306
  throw CustomError.cannotDeleteDirectory
305
307
  }
306
308
  }
307
309
 
308
310
  private func unflatFolder(source: URL, dest: URL) throws -> Bool {
309
- let index: URL = source.appendingPathComponent("index.html")
311
+ let index: URL = source.appendingPathComponent(self.indexHTML)
310
312
  do {
311
313
  let files: [String] = try FileManager.default.contentsOfDirectory(atPath: source.path)
312
314
  if files.count == 1 && source.appendingPathComponent(files[0]).isDirectory && !FileManager.default.fileExists(atPath: index.path) {
@@ -317,7 +319,7 @@ extension CustomError: LocalizedError {
317
319
  return false
318
320
  }
319
321
  } catch {
320
- print("\(self.TAG) File not moved. source: \(source.path) dest: \(dest.path)")
322
+ print("\(self.tag) File not moved. source: \(source.path) dest: \(dest.path)")
321
323
  throw CustomError.cannotUnflat
322
324
  }
323
325
  }
@@ -328,14 +330,14 @@ extension CustomError: LocalizedError {
328
330
  let checksum: uLong = fileData.withUnsafeBytes { crc32(0, $0.bindMemory(to: Bytef.self).baseAddress, uInt(fileData.count)) }
329
331
  return String(format: "%08X", checksum).lowercased()
330
332
  } catch {
331
- print("\(self.TAG) Cannot get checksum: \(filePath.path)", error)
333
+ print("\(self.tag) Cannot get checksum: \(filePath.path)", error)
332
334
  return ""
333
335
  }
334
336
  }
335
337
 
336
338
  private func decryptFile(filePath: URL, sessionKey: String) throws {
337
339
  if (self.privateKey ?? "").isEmpty || (sessionKey ?? "").isEmpty {
338
- print("\(self.TAG) Cannot found privateKey or sessionKey")
340
+ print("\(self.tag) Cannot found privateKey or sessionKey")
339
341
  return
340
342
  }
341
343
  do {
@@ -357,7 +359,7 @@ extension CustomError: LocalizedError {
357
359
 
358
360
  try decryptedData.write(to: filePath)
359
361
  } catch {
360
- print("\(self.TAG) Cannot decode: \(filePath.path)", error)
362
+ print("\(self.tag) Cannot decode: \(filePath.path)", error)
361
363
  throw CustomError.cannotDecode
362
364
  }
363
365
  }
@@ -377,16 +379,16 @@ extension CustomError: LocalizedError {
377
379
  private func createInfoObject() -> InfoObject {
378
380
  return InfoObject(
379
381
  platform: "ios",
380
- device_id: self.deviceID,
381
- app_id: self.appId,
382
- custom_id: self.customId,
383
- version_build: self.versionName,
384
- version_code: self.versionCode,
385
- version_os: self.versionOs,
386
- version_name: self.getCurrentBundle().getVersionName(),
387
- plugin_version: self.PLUGIN_VERSION,
388
- is_emulator: self.isEmulator(),
389
- is_prod: self.isProd(),
382
+ deviceId: self.deviceID,
383
+ appId: self.appId,
384
+ customId: self.customId,
385
+ versionBuild: self.versionName,
386
+ versionCode: self.versionCode,
387
+ versionOS: self.versionOs,
388
+ versionName: self.getCurrentBundle().getVersionName(),
389
+ pluginVersion: self.pluginVersion,
390
+ isEmulator: self.isEmulator(),
391
+ isProd: self.isProd(),
390
392
  action: nil,
391
393
  channel: nil
392
394
  )
@@ -396,7 +398,7 @@ extension CustomError: LocalizedError {
396
398
  let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
397
399
  let latest: AppVersion = AppVersion()
398
400
  let parameters: InfoObject = self.createInfoObject()
399
- print("\(self.TAG) Auto-update parameters: \(parameters)")
401
+ print("\(self.tag) Auto-update parameters: \(parameters)")
400
402
  let request = AF.request(url, method: .post, parameters: parameters, encoder: JSONParameterEncoder.default, requestModifier: { $0.timeoutInterval = self.timeout })
401
403
 
402
404
  request.validate().responseDecodable(of: AppVersionDec.self) { response in
@@ -420,11 +422,11 @@ extension CustomError: LocalizedError {
420
422
  if let message = response.value?.message {
421
423
  latest.message = message
422
424
  }
423
- if let sessionKey = response.value?.session_key {
425
+ if let sessionKey = response.value?.sessionKey {
424
426
  latest.sessionKey = sessionKey
425
427
  }
426
428
  case let .failure(error):
427
- print("\(self.TAG) Error getting Latest", response.value ?? "", error )
429
+ print("\(self.tag) Error getting Latest", response.value ?? "", error )
428
430
  latest.message = "Error getting Latest \(String(describing: response.value))"
429
431
  latest.error = "response_error"
430
432
  }
@@ -435,9 +437,9 @@ extension CustomError: LocalizedError {
435
437
  }
436
438
 
437
439
  private func setCurrentBundle(bundle: String) {
438
- UserDefaults.standard.set(bundle, forKey: self.CAP_SERVER_PATH)
440
+ UserDefaults.standard.set(bundle, forKey: self.capServerPath)
439
441
  UserDefaults.standard.synchronize()
440
- print("\(self.TAG) Current bundle set to: \((bundle ?? "").isEmpty ? BundleInfo.ID_BUILTIN : bundle)")
442
+ print("\(self.tag) Current bundle set to: \((bundle ?? "").isEmpty ? BundleInfo.idBuiltin : bundle)")
441
443
  }
442
444
 
443
445
  public func download(url: URL, version: String, sessionKey: String) throws -> BundleInfo {
@@ -472,11 +474,11 @@ extension CustomError: LocalizedError {
472
474
  self.notifyDownload(id, 100)
473
475
  try self.deleteFolder(source: fileURL)
474
476
  } catch {
475
- print("\(self.TAG) download unzip error", error)
477
+ print("\(self.tag) download unzip error", error)
476
478
  mainError = error as NSError
477
479
  }
478
480
  case let .failure(error):
479
- print("\(self.TAG) download error", response.value!, error)
481
+ print("\(self.tag) download error", response.value!, error)
480
482
  mainError = error as NSError
481
483
  }
482
484
  }
@@ -498,7 +500,7 @@ extension CustomError: LocalizedError {
498
500
  do {
499
501
  let files: [String] = try FileManager.default.contentsOfDirectory(atPath: dest.path)
500
502
  var res: [BundleInfo] = []
501
- print("\(self.TAG) list File : \(dest.path)")
503
+ print("\(self.tag) list File : \(dest.path)")
502
504
  if dest.exist {
503
505
  for id: String in files {
504
506
  res.append(self.getBundleInfo(id: id))
@@ -506,7 +508,7 @@ extension CustomError: LocalizedError {
506
508
  }
507
509
  return res
508
510
  } catch {
509
- print("\(self.TAG) No version available \(dest.path)")
511
+ print("\(self.tag) No version available \(dest.path)")
510
512
  return []
511
513
  }
512
514
  }
@@ -514,7 +516,7 @@ extension CustomError: LocalizedError {
514
516
  public func delete(id: String, removeInfo: Bool) -> Bool {
515
517
  let deleted: BundleInfo = self.getBundleInfo(id: id)
516
518
  if deleted.isBuiltin() || self.getCurrentBundleId() == id {
517
- print("\(self.TAG) Cannot delete \(id)")
519
+ print("\(self.tag) Cannot delete \(id)")
518
520
  return false
519
521
  }
520
522
  let destHot: URL = documentsDir.appendingPathComponent(bundleDirectoryHot).appendingPathComponent(id)
@@ -522,12 +524,12 @@ extension CustomError: LocalizedError {
522
524
  do {
523
525
  try FileManager.default.removeItem(atPath: destHot.path)
524
526
  } catch {
525
- print("\(self.TAG) Hot Folder \(destHot.path), not removed.")
527
+ print("\(self.tag) Hot Folder \(destHot.path), not removed.")
526
528
  }
527
529
  do {
528
530
  try FileManager.default.removeItem(atPath: destPersist.path)
529
531
  } catch {
530
- print("\(self.TAG) Folder \(destPersist.path), not removed.")
532
+ print("\(self.tag) Folder \(destPersist.path), not removed.")
531
533
  return false
532
534
  }
533
535
  if removeInfo {
@@ -535,7 +537,7 @@ extension CustomError: LocalizedError {
535
537
  } else {
536
538
  self.saveBundleInfo(id: id, bundle: deleted.setStatus(status: BundleStatus.DELETED.localizedString))
537
539
  }
538
- print("\(self.TAG) bundle delete \(deleted.getVersionName())")
540
+ print("\(self.tag) bundle delete \(deleted.getVersionName())")
539
541
  self.sendStats(action: "delete", versionName: deleted.getVersionName())
540
542
  return true
541
543
  }
@@ -555,8 +557,8 @@ extension CustomError: LocalizedError {
555
557
  private func bundleExists(id: String) -> Bool {
556
558
  let destHot: URL = self.getPathHot(id: id)
557
559
  let destHotPersist: URL = self.getPathPersist(id: id)
558
- let indexHot: URL = destHot.appendingPathComponent("index.html")
559
- let indexPersist: URL = destHotPersist.appendingPathComponent("index.html")
560
+ let indexHot: URL = destHot.appendingPathComponent(self.indexHTML)
561
+ let indexPersist: URL = destHotPersist.appendingPathComponent(self.indexHTML)
560
562
  let url: URL = self.getBundleDirectory(id: id)
561
563
  let bundleIndo: BundleInfo = self.getBundleInfo(id: id)
562
564
  if url.isDirectory && destHotPersist.isDirectory && indexHot.exist && indexPersist.exist && !bundleIndo.isDeleted() {
@@ -594,7 +596,7 @@ extension CustomError: LocalizedError {
594
596
  }
595
597
 
596
598
  public func reset(isInternal: Bool) {
597
- print("\(self.TAG) reset: \(isInternal)")
599
+ print("\(self.tag) reset: \(isInternal)")
598
600
  self.setCurrentBundle(bundle: "")
599
601
  self.setFallbackBundle(fallback: Optional<BundleInfo>.none)
600
602
  _ = self.setNextBundle(next: Optional<String>.none)
@@ -606,14 +608,14 @@ extension CustomError: LocalizedError {
606
608
  public func setSuccess(bundle: BundleInfo, autoDeletePrevious: Bool) {
607
609
  self.setBundleStatus(id: bundle.getId(), status: BundleStatus.SUCCESS)
608
610
  let fallback: BundleInfo = self.getFallbackBundle()
609
- print("\(self.TAG) Fallback bundle is: \(fallback.toString())")
610
- print("\(self.TAG) Version successfully loaded: \(bundle.toString())")
611
+ print("\(self.tag) Fallback bundle is: \(fallback.toString())")
612
+ print("\(self.tag) Version successfully loaded: \(bundle.toString())")
611
613
  if autoDeletePrevious && !fallback.isBuiltin() {
612
614
  let res = self.delete(id: fallback.getId())
613
615
  if res {
614
- print("\(self.TAG) Deleted previous bundle: \(fallback.toString())")
616
+ print("\(self.tag) Deleted previous bundle: \(fallback.toString())")
615
617
  } else {
616
- print("\(self.TAG) Failed to delete previous bundle: \(fallback.toString())")
618
+ print("\(self.tag) Failed to delete previous bundle: \(fallback.toString())")
617
619
  }
618
620
  }
619
621
  self.setFallbackBundle(fallback: bundle)
@@ -626,7 +628,7 @@ extension CustomError: LocalizedError {
626
628
  func setChannel(channel: String) -> SetChannel {
627
629
  let setChannel: SetChannel = SetChannel()
628
630
  if (self.channelUrl ?? "").isEmpty {
629
- print("\(self.TAG) Channel URL is not set")
631
+ print("\(self.tag) Channel URL is not set")
630
632
  setChannel.message = "Channel URL is not set"
631
633
  setChannel.error = "missing_config"
632
634
  return setChannel
@@ -650,7 +652,7 @@ extension CustomError: LocalizedError {
650
652
  setChannel.message = message
651
653
  }
652
654
  case let .failure(error):
653
- print("\(self.TAG) Error set Channel", response.value, error)
655
+ print("\(self.tag) Error set Channel", response.value, error)
654
656
  setChannel.message = "Error set Channel \(String(describing: response.value))"
655
657
  setChannel.error = "response_error"
656
658
  }
@@ -663,7 +665,7 @@ extension CustomError: LocalizedError {
663
665
  func getChannel() -> GetChannel {
664
666
  let getChannel: GetChannel = GetChannel()
665
667
  if (self.channelUrl ?? "").isEmpty {
666
- print("\(self.TAG) Channel URL is not set")
668
+ print("\(self.tag) Channel URL is not set")
667
669
  getChannel.message = "Channel URL is not set"
668
670
  getChannel.error = "missing_config"
669
671
  return getChannel
@@ -691,7 +693,7 @@ extension CustomError: LocalizedError {
691
693
  getChannel.allowSet = allowSet
692
694
  }
693
695
  case let .failure(error):
694
- print("\(self.TAG) Error get Channel", response.value ?? "", error)
696
+ print("\(self.tag) Error get Channel", response.value ?? "", error)
695
697
  getChannel.message = "Error get Channel \(String(describing: response.value)))"
696
698
  getChannel.error = "response_error"
697
699
  }
@@ -712,34 +714,34 @@ extension CustomError: LocalizedError {
712
714
  request.responseData { response in
713
715
  switch response.result {
714
716
  case .success:
715
- print("\(self.TAG) Stats send for \(action), version \(versionName)")
717
+ print("\(self.tag) Stats send for \(action), version \(versionName)")
716
718
  case let .failure(error):
717
- print("\(self.TAG) Error sending stats: ", response.value, error)
719
+ print("\(self.tag) Error sending stats: ", response.value, error)
718
720
  }
719
721
  }
720
722
  }
721
723
  }
722
724
 
723
725
  public func getBundleInfo(id: String?) -> BundleInfo {
724
- var trueId = BundleInfo.VERSION_UNKNOWN
726
+ var trueId = BundleInfo.versionUnknown
725
727
  if id != nil {
726
728
  trueId = id!
727
729
  }
728
- print("\(self.TAG) Getting info for bundle [\(trueId)]")
730
+ print("\(self.tag) Getting info for bundle [\(trueId)]")
729
731
  let result: BundleInfo
730
- if BundleInfo.ID_BUILTIN == trueId {
732
+ if BundleInfo.idBuiltin == trueId {
731
733
  result = BundleInfo(id: trueId, version: "", status: BundleStatus.SUCCESS, checksum: "")
732
- } else if BundleInfo.VERSION_UNKNOWN == trueId {
734
+ } else if BundleInfo.versionUnknown == trueId {
733
735
  result = BundleInfo(id: trueId, version: "", status: BundleStatus.ERROR, checksum: "")
734
736
  } else {
735
737
  do {
736
- result = try UserDefaults.standard.getObj(forKey: "\(trueId)\(self.INFO_SUFFIX)", castTo: BundleInfo.self)
738
+ result = try UserDefaults.standard.getObj(forKey: "\(trueId)\(self.infoSuffix)", castTo: BundleInfo.self)
737
739
  } catch {
738
- print("\(self.TAG) Failed to parse info for bundle [\(trueId)]", error.localizedDescription)
740
+ print("\(self.tag) Failed to parse info for bundle [\(trueId)]", error.localizedDescription)
739
741
  result = BundleInfo(id: trueId, version: "", status: BundleStatus.PENDING, checksum: "")
740
742
  }
741
743
  }
742
- print("\(self.TAG) Returning info bundle [\(result.toString())]")
744
+ print("\(self.tag) Returning info bundle [\(result.toString())]")
743
745
  return result
744
746
  }
745
747
 
@@ -759,32 +761,32 @@ extension CustomError: LocalizedError {
759
761
 
760
762
  private func saveBundleInfo(id: String, bundle: BundleInfo?) {
761
763
  if bundle != nil && (bundle!.isBuiltin() || bundle!.isUnknown()) {
762
- print("\(self.TAG) Not saving info for bundle [\(id)]", bundle!.toString())
764
+ print("\(self.tag) Not saving info for bundle [\(id)]", bundle!.toString())
763
765
  return
764
766
  }
765
767
  if bundle == nil {
766
- print("\(self.TAG) Removing info for bundle [\(id)]")
767
- UserDefaults.standard.removeObject(forKey: "\(id)\(self.INFO_SUFFIX)")
768
+ print("\(self.tag) Removing info for bundle [\(id)]")
769
+ UserDefaults.standard.removeObject(forKey: "\(id)\(self.infoSuffix)")
768
770
  } else {
769
771
  let update = bundle!.setId(id: id)
770
- print("\(self.TAG) Storing info for bundle [\(id)]", update.toString())
772
+ print("\(self.tag) Storing info for bundle [\(id)]", update.toString())
771
773
  do {
772
- try UserDefaults.standard.setObj(update, forKey: "\(id)\(self.INFO_SUFFIX)")
774
+ try UserDefaults.standard.setObj(update, forKey: "\(id)\(self.infoSuffix)")
773
775
  } catch {
774
- print("\(self.TAG) Failed to save info for bundle [\(id)]", error.localizedDescription)
776
+ print("\(self.tag) Failed to save info for bundle [\(id)]", error.localizedDescription)
775
777
  }
776
778
  }
777
779
  UserDefaults.standard.synchronize()
778
780
  }
779
781
 
780
782
  public func setVersionName(id: String, version: String) {
781
- print("\(self.TAG) Setting version for folder [\(id)] to \(version)")
783
+ print("\(self.tag) Setting version for folder [\(id)] to \(version)")
782
784
  let info = self.getBundleInfo(id: id)
783
785
  self.saveBundleInfo(id: id, bundle: info.setVersionName(version: version))
784
786
  }
785
787
 
786
788
  private func setBundleStatus(id: String, status: BundleStatus) {
787
- print("\(self.TAG) Setting status for bundle [\(id)] to \(status)")
789
+ print("\(self.tag) Setting status for bundle [\(id)] to \(status)")
788
790
  let info = self.getBundleInfo(id: id)
789
791
  self.saveBundleInfo(id: id, bundle: info.setStatus(status: status.localizedString))
790
792
  }
@@ -794,38 +796,38 @@ extension CustomError: LocalizedError {
794
796
  }
795
797
 
796
798
  public func getCurrentBundleId() -> String {
797
- guard let bundlePath: String = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) else {
798
- return BundleInfo.ID_BUILTIN
799
+ guard let bundlePath: String = UserDefaults.standard.string(forKey: self.capServerPath) else {
800
+ return BundleInfo.idBuiltin
799
801
  }
800
802
  if (bundlePath ?? "").isEmpty {
801
- return BundleInfo.ID_BUILTIN
803
+ return BundleInfo.idBuiltin
802
804
  }
803
805
  let bundleID: String = bundlePath.components(separatedBy: "/").last ?? bundlePath
804
806
  return bundleID
805
807
  }
806
808
 
807
809
  public func isUsingBuiltin() -> Bool {
808
- return (UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) ?? "") == self.DEFAULT_FOLDER
810
+ return (UserDefaults.standard.string(forKey: self.capServerPath) ?? "") == self.defaultFolder
809
811
  }
810
812
 
811
813
  public func getFallbackBundle() -> BundleInfo {
812
- let id: String = UserDefaults.standard.string(forKey: self.FALLBACK_VERSION) ?? BundleInfo.ID_BUILTIN
814
+ let id: String = UserDefaults.standard.string(forKey: self.fallbackVersion) ?? BundleInfo.idBuiltin
813
815
  return self.getBundleInfo(id: id)
814
816
  }
815
817
 
816
818
  private func setFallbackBundle(fallback: BundleInfo?) {
817
- UserDefaults.standard.set(fallback == nil ? BundleInfo.ID_BUILTIN : fallback!.getId(), forKey: self.FALLBACK_VERSION)
819
+ UserDefaults.standard.set(fallback == nil ? BundleInfo.idBuiltin : fallback!.getId(), forKey: self.fallbackVersion)
818
820
  UserDefaults.standard.synchronize()
819
821
  }
820
822
 
821
823
  public func getNextBundle() -> BundleInfo? {
822
- let id: String? = UserDefaults.standard.string(forKey: self.NEXT_VERSION)
824
+ let id: String? = UserDefaults.standard.string(forKey: self.nextVersion)
823
825
  return self.getBundleInfo(id: id)
824
826
  }
825
827
 
826
828
  public func setNextBundle(next: String?) -> Bool {
827
829
  guard let nextId: String = next else {
828
- UserDefaults.standard.removeObject(forKey: self.NEXT_VERSION)
830
+ UserDefaults.standard.removeObject(forKey: self.nextVersion)
829
831
  UserDefaults.standard.synchronize()
830
832
  return false
831
833
  }
@@ -834,7 +836,7 @@ extension CustomError: LocalizedError {
834
836
  if !newBundle.isBuiltin() && !bundle.exist {
835
837
  return false
836
838
  }
837
- UserDefaults.standard.set(nextId, forKey: self.NEXT_VERSION)
839
+ UserDefaults.standard.set(nextId, forKey: self.nextVersion)
838
840
  UserDefaults.standard.synchronize()
839
841
  self.setBundleStatus(id: nextId, status: BundleStatus.PENDING)
840
842
  return true