44 lines
1.1 KiB
Swift
44 lines
1.1 KiB
Swift
//
|
|
// SettingsBaseTableViewController.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Andrea Busi on 10/06/24.
|
|
// Copyright © 2024 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
@objc
|
|
class SettingsBaseTableViewController: UITableViewController {
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
|
|
if isMovingFromParent {
|
|
Self.saveSettings()
|
|
}
|
|
}
|
|
|
|
// MARK: - Class
|
|
|
|
@objc class func saveSettings() {
|
|
saveSettings { _ in
|
|
// nope
|
|
}
|
|
}
|
|
|
|
@objc class func saveSettings(
|
|
completion: @escaping (_ success: Bool) -> Void
|
|
) {
|
|
|
|
let url = EQNGeneratoreURLServer.urlInvioImpostazioniNotifiche()
|
|
ServerRequest.default().inviaInformazioniAlServer(with: url, richiesta: .impostazioniNotifiche) { _ in
|
|
print("[SETTINGS] Settings saved successfully")
|
|
completion(true)
|
|
} failure: { error in
|
|
print("[SETTINGS] Settings saved failed. Error: \(error?.localizedDescription ?? "n.d.")")
|
|
completion(false)
|
|
}
|
|
}
|
|
}
|