2016-10-26 7 views
4

솔루션 코드 :iOS 10 UNUserNotificationCenter를 사용하여 보류중인 알림 목록을 보는 방법은 무엇입니까?

let center = UNUserNotificationCenter.current() 
print(center.getPendingNotificationRequests(completionHandler: { error in 
     // error handling here 
    })) 

내 원래의 게시물 : 나는 UIApplication.shared.scheduledLocalNotifications 감가 상각되면서 UNUserNotificationCenter를 통해 대기 알림 목록을 얻기 위해 노력하고

.

let center = UNUserNotificationCenter.current() 
    print(UNUserNotificationCenter.getPendingNotificationRequests(center)) 

그러나이 인쇄 "(기능)"

내가 사용하고 코드입니다. getPendingNotificationRequests에는 UNUserNotificationCenter 매개 변수가 필요하며 그 외에 무엇이 될지 생각할 수 없습니다.

감사

+0

전화, 콜백 핸들러 https://developer.apple.com/reference/usernotifications/unusernotificationcenter/1649513-getpendingnotificationrequests을 제공 – Paulw11

답변

13

getPendingNotificationRequests 호출이 완료 폐쇄 요청의 배열을 전달합니다. 이 같은 시도 :하지 클래스 센터 '`에서 작동

let center = UNUserNotificationCenter.current() 
center.getPendingNotificationRequests(completionHandler: { requests in 
    for request in requests { 
     print(request) 
    } 
})