매일 반복 될 때 로컬 알림에서 메시지를 업데이트하는 방법을 찾으려고합니다.iOS 10에서 일일 로컬 알림 메시지를 업데이트하는 방법은 무엇입니까?
func scheduler(at date: Date, numOfNotes: Int)
{
let calendar = Calendar(identifier: .gregorian)
let components = calendar.dateComponents(in: .current, from: date)
let newComponents = DateComponents(calendar: calendar, timeZone: .current, hour: components.hour, minute: components.minute)
let trigger = UNCalendarNotificationTrigger(dateMatching: newComponents, repeats: true)
content.badge = numOfNotes as NSNumber
content.body = "REMINDER: " + String(numOfNotes) + " needs to be looked at!"
content.sound = UNNotificationSound.default()
let request = UNNotificationRequest(identifier: "reminderNotification", content: content, trigger: trigger)
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().add(request) {(error) in
}
}
내가 UserDefaults
에 numOfNotes
를 저장하고 :
현재 내 AppDelegate에 다음 코드를 가지고있다. 지정된 시간에 매일 알림 반복을 가지고 true
에 repeats
매개 변수를 설정할 때, numOfNotes
이 아니라 그러나
func remindMeSwitch(_ remindMeSwitch: UISwitch)
{
numOfNotes = UserDefaults.standard.integer(forKey: "Notes")
let delegate = UIApplication.shared.delegate as? AppDelegate
delegate?.scheduler(at: time, numOfNotes: numOfNotes)
}
: 나는 scheduler
기능과 같이 호출로 전환 될 때 내 UITableViewCell
에서 UISwitch
, 그이 나는 한 번 불렀다. 나는 UISwitch
을 토글했다.
알림을 매일 알림으로 설정할 수 있지만 필요에 따라 알림 메시지를 계속 업데이트하려면 어떻게해야합니까?
감사합니다.
은 당신이 이것을 달성하기 위해 적절한 메시지로 개별 비 반복 알림을 예약해야 할 것 보인다. – Losiowaty
@Losiowaty, 나는 그럴 수 있었다고 생각하지만 카운트가 변경 될 때마다 일정을 다시 잡을 필요가 없기를 바랄 것입니다. – Pangu
알림 서비스 앱 확장을 추가 할 수는 있지만 그 전화가 필요한지 확실하지 않습니다. 현지 알림. 또한 iOS 10에서만 사용할 수 있습니다. – Losiowaty