5minho / DreamRecorder

mino & bran BoostCamp Project
6 stars 0 forks source link

비활성화 된 알람 활성화 후 비활성화 -> SoundManager 알림음 울림 #57

Closed YoonJuHo closed 6 years ago

YoonJuHo commented 6 years ago

의도된 로직

활성화 또는 비활성화 -> isOn 바뀜

-> DataStore에서 DB update하고 alarms(메모리에 있는 배열)에도 업데이트

-> post AlarmDidUpdate --> Scheduler가 다음 노티피케이션 date를 계산

-> Scheduler가 post nextDateDidChange

-> SoundManager가 nextDate를 다시 할당하고 추적.

YoonJuHo commented 6 years ago

로직은 이상이 없었으나.. Thread 가 달라서 delete되기전에 nextDate를 할당됨.

iOS 10이상부터는 UserNotificationCenter에서 Pending Requests를 불러올 수 있는데 이때 LocalNotification(iOS 9)과는 다르게 Completion Block을 통해서 Requests를 돌려받는다. 따라서 SoundManager에게 알려주는 nextDateDidChange를 completion block안에서 post해주어야만 정상적으로 nextNotification이 삭제된 이후에 가까운 노티피케이션이 정상적으로 계산될 수 있음.