0
사용자를 생성하는 앱이 있습니다. 각 사용자는 개체를 만들 수 있습니다. 각 사용자에게 해당 개체에 대한 로컬 알림을 설정할 수있는 권한을 부여합니다. 알림의 식별자에 대한 내 이름 지정 규칙은 생성 된 개체 이름 + 개체 이름을 사용하는 것입니다. 내가 그 사람이 앱에서 삭제되면 모든 알림을 삭제하고 싶습니다.식별자를 기반으로 여러 로컬 알림을 제거하려고 시도했습니다.
필자는 그 사람의 모든 객체를 반복하여 그 이름을 사용하여 삭제해야하는 알림을 식별해야합니다. 유형의 값 UNNotificaionRequest 어떤 멤버가 포함 없습니다 : 여기
내가 그냥 작동하지 않는 것 // remove local notifications
let center = UNUserNotificationCenter.current()
let personToSerch = person.name!
var filterdItemsArray = [String]()
center.getPendingNotificationRequests { (notifications) in
print("Count: \(notifications.count)")
func filterContentForSearchText(searchText: String) {
filterdItemsArray = notifications.filter { item in
return item.contains(searchText)
}
}
filterContentForSearchText(searchText: personToSerch)
print("\(filterdItemsArray.count) count of the filter array")
}
center.removePendingNotificationRequests(withIdentifiers: filterdItemsArray)
을 시도하고 내 리턴 라인 읽기에서 오류가 발생하는 것이다.
답을 따르지 않아 죄송합니다. idtodelete는 어디에서 왔습니까? – icekomo
idtodelete는 사용자의 경우 삭제하려는 personToSerch입니다. – CST
달성하고자하는 것을 보여주기 위해 코드를 업데이트했습니다. 그 사람과 관련된 모든 알림을 찾아야합니다. 하나 이상있을 수 있습니다, 그리고 그 사람 이름을 해당 배열에 대한 술어로 사용하여 배열을 만들 수 있어야합니다. – icekomo