From e3dcfa629f00f078e480c4f3410c5fb39cd619e9 Mon Sep 17 00:00:00 2001 From: Stephan Diederich Date: Tue, 10 Sep 2013 17:06:00 +0200 Subject: [PATCH] don't register twice --- Classes/BITAuthenticator.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Classes/BITAuthenticator.m b/Classes/BITAuthenticator.m index 4c3985b844..9b2e224fc3 100644 --- a/Classes/BITAuthenticator.m +++ b/Classes/BITAuthenticator.m @@ -462,14 +462,16 @@ static NSString* const kBITAuthenticatorLastAuthenticatedVersionKey = @"BITAuthe } - (void) registerObservers { - __weak typeof(self) weakSelf = self; - _appDidBecomeActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification - object:nil - queue:NSOperationQueue.mainQueue - usingBlock:^(NSNotification *note) { - typeof(self) strongSelf = weakSelf; - [strongSelf applicationDidBecomeActive:note]; - }]; + if(nil == _appDidBecomeActiveObserver) { + __weak typeof(self) weakSelf = self; + _appDidBecomeActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification + object:nil + queue:NSOperationQueue.mainQueue + usingBlock:^(NSNotification *note) { + typeof(self) strongSelf = weakSelf; + [strongSelf applicationDidBecomeActive:note]; + }]; + } } - (void) unregisterObservers {