huynguyencong / NHNetworkTime

A simple network time protocol SNTP open source for iOS, get the correct time.
Apache License 2.0
118 stars 22 forks source link

Did not update correct time after app is moved from background to foreground #33

Closed baigozin closed 3 years ago

baigozin commented 4 years ago

When app is moving to the background, UIApplicationDidEnterBackgroundNotification is observed and every NHNetAssociation execute [self finish], whitch execte [self unregisterObservations], which remove all observers, including UIApplicationWillEnterForegroundNotification.

So, after app is on foreground, there is no observers to make [self enable] for NHNetAssociation's objects.

Workaround - execte [[NHNetworkClock sharedNetworkClock] synchronize] in applicationDidBecomeActive:, not in didFinishLaunchingWithOptions: method of appDelegate.

huynguyencong commented 3 years ago

Thanks for you feedback. Just fixed it. Please update new version in the next day.