В моем приложении я отправляю тихие push-уведомления "content-available": 1
.
На стороне получателя они могут перейти к настройкам внутри приложения и включить уведомления и звук.
Я знаюЯ могу использовать этот код, чтобы узнать статус либо внутри приложения
UNUserNotificationCenter.current().getNotificationSettings { (settings: UNNotificationSettings) in
guard settings.authorizationStatus == .authorized else { return }
let soundSetting: UNNotificationSetting = settings.soundSetting
switch soundSetting {
case .enabled:
print("enabled")
case .disabled:
print("disabled")
case .notSupported:
print("???")
}
let badgeSetting: UNNotificationSetting = settings.badgeSetting
switch badgeSetting {
case .enabled:
print("enabled")
case .disabled:
print("disabled")
case .notSupported:
print("???")
}
UIApplication.shared.registerForRemoteNotifications()
}
Вопрос в том, как изменить статус самого notification
или sound
из самого приложениябез отправки пользователя за пределы приложения?
lazy var switchNotificationControl: UISwitch = { ... }
lazy var switchSoundControl: UISwitch = { ... }
@objc func switchValueDidChange(_ sender: UISwitch) {
if (sender.isOn == true) {
// set notifications to on/true or sound to on/true
} else {
// set notifications to off/false or sound to off/false
}
}