Skip to content

Commit fc12510

Browse files
Cleaned up Reachability code.
1 parent c90b36a commit fc12510

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

OptimizelySDKEventDispatcher/OptimizelySDKEventDispatcher/OPTLYEventDispatcher.m

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
***************************************************************************/
1616

1717
#import "OPTLYEventDispatcher.h"
18-
#import <OptimizelySDKShared/Reachability.h>
1918

19+
// TODO - Flush events when network connection has become available.
2020

2121
// --- Event URLs ----
22-
NSString * const OPTLYEventDispatcherHostName = @"https://logx.optimizely.com";
2322
NSString * const OPTLYEventDispatcherImpressionEventURL = @"https://logx.optimizely.com/log/decision";
2423
NSString * const OPTLYEventDispatcherConversionEventURL = @"https://logx.optimizely.com/log/event";
2524

@@ -448,38 +447,18 @@ - (void)setupApplicationNotificationHandlers {
448447
object:app];
449448
}
450449

451-
- (void)applicationDidFinishLaunching:(id)notificaton {
452-
453-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityDidChange:) name:kReachabilityChangedNotification object:nil];
454-
455-
// Initialize Reachability
456-
Reachability *hostReachability = [Reachability reachabilityWithHostName:OPTLYEventDispatcherHostName];
457-
Reachability *internetReachability = [Reachability reachabilityForInternetConnection];
458-
// Start Monitoring
459-
[internetReachability startNotifier];
460-
[hostReachability startNotifier];
461-
462-
OPTLYLogInfo(@"applicationDidBecomeActive");
463-
}
464450

465-
- (void)reachabilityDidChange:(NSNotification *)notification {
466-
Reachability *reachability = (Reachability *)[notification object];
467-
468-
if ([reachability currentReachabilityStatus] != NotReachable) {
469-
OPTLYLogInfo(@"Network is reachable.");
470-
} else {
471-
OPTLYLogInfo(@"Network is unreachable");
472-
}
451+
- (void)applicationDidFinishLaunching:(id)notificaton {
452+
[self flushEvents];
453+
OPTLYLogInfo(@"applicationDidFinishLaunching");
473454
}
474455

475456
- (void)applicationDidBecomeActive:(id)notificaton {
476-
[self flushEvents];
477457
OPTLYLogInfo(@"applicationDidBecomeActive");
478458
}
479459

480460
- (void)applicationDidEnterBackground:(id)notification {
481461
[self flushEvents];
482-
//[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
483462
OPTLYLogInfo(@"applicationDidEnterBackground");
484463
}
485464

@@ -493,10 +472,13 @@ - (void)applicationWillResignActive:(id)notification {
493472

494473
- (void)applicationWillTerminate:(id)notification {
495474
[self flushEvents];
496-
//[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
497475
OPTLYLogInfo(@"applicationWillTerminate");
498476
}
499477

478+
- (void)dealloc {
479+
[[NSNotificationCenter defaultCenter] removeObserver:self];
480+
}
481+
500482
# pragma mark - Helper Methods
501483
- (BOOL)haveEventsToSend:(OPTLYDataStoreEventType)eventType cachedData:(BOOL)cachedData
502484
{

0 commit comments

Comments
 (0)