// // SettingsViewController.swift // Wallet // // Created by Saveliy Stavitsky on 9/9/21. // Copyright © 2021 AM. All rights reserved. // import UIKit final class SettingsViewController: UIViewController { @IBOutlet var settingsView: AccountViewSettings! deinit { NotificationCenter.default.removeObserver(self) } override func viewDidLoad() { super.viewDidLoad() self.title = L10n.Account.Settings.title self.navigationItem.leftBarButtonItem = .pop(self) self.settingsView.parent = self self.notificationSwitch() NotificationCenter.default.addObserver(self, selector: #selector(notificationSwitch), name: UIApplication.willEnterForegroundNotification, object: nil) // Do any additional setup after loading the view. } @objc func notificationSwitch() { let center = UNUserNotificationCenter.current() center.getNotificationSettings { settings in switch settings.authorizationStatus { case .authorized, .provisional: DispatchQueue.main.async { self.settingsView.notificationsEnabledLabel.text = L10n.Account.Settings.notificationsEnabled } default: DispatchQueue.main.async { self.settingsView.notificationsEnabledLabel.text = L10n.Account.Settings.notificationsDisabled } } } } }