5minho / DreamRecorder

mino & bran BoostCamp Project
6 stars 0 forks source link

Notification을 복제하고 앱을 종료했다가 다시 키면 inactive가 안되고 있음. #73

Closed YoonJuHo closed 6 years ago

YoonJuHo commented 6 years ago

원인: AlarmScheduler의 이니셜라이져에서 updateNotificationsIfNeeded()를 호출하여 업데이트 되어야 할 노티피케이션들을 정리하는데 이때 getPendingNotificationRequests()를 두번(따로따로) 호출하고 있었음.

즉 백그라운드 스레드에서 운용되는 getPendingNotificationRequests가 각각 실행되고 있으므로 Duplicated된 노티피케이션을 삭제한 후에 AlarmSchedulerNotificationDidDelivered호출을 보장하고 있지 않았음.

따라서 하나의 getPendingNotificationRequests로 묶고 모든 삭제가 완료된 후에 AlarmSchedulerNotificationDidDelivered를 통해 AlarmDataStore가 올바른 처리가 되도록 해야함.

YoonJuHo commented 6 years ago

수정내용: AlarmScheduler에서 최초 실행시(Scheduler생성시) updateNotificationsIfNeeded()를 통해 모든 노티피케이션을 검사하여 복제된 노티피케이션과 스누즈 노티피케이션을 삭제한다. 또한 해당 블럭(getPendingNotificationRequests Completion클로저)내에서 삭제가 반영된 getPendingNotificationRequests를 다시 호출하여 작업을 한다. 기존 getPendingNotificationRequests()에서 작업하기에는 Completion에 넘겨오는 인자가 let으로서 삭제된 Notification이 반영이 되어있지않아 지워지지 않는다.