Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions Automattic-Tracks-iOS/ABTesting/ExPlat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Cocoa
service: ExPlatService? = nil) {
self.service = service ?? ExPlatService(configuration: configuration)
super.init()
subscribeToNotifications()
ExPlat.shared = self
}

Expand All @@ -39,10 +38,6 @@ import Cocoa
anonId: anonId))
}

deinit {
unsubscribeFromNotifications()
}

/// Only refresh if the TTL has expired
///
public func refreshIfNeeded(completion: (() -> Void)? = nil) {
Expand Down Expand Up @@ -90,34 +85,4 @@ import Cocoa
return .treatment(variation)
}
}

/// Check if the app is entering background and/or foreground
/// and start/stop the timers
///
private func subscribeToNotifications() {
let notificationCenter = NotificationCenter.default

#if os(iOS) || os(watchOS) || os(tvOS)
notificationCenter.addObserver(self, selector: #selector(applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
#elseif os(macOS)
notificationCenter.addObserver(self, selector: #selector(applicationWillEnterForeground), name: NSApplication.willBecomeActiveNotification, object: nil)
#endif
}

private func unsubscribeFromNotifications() {
let notificationCenter = NotificationCenter.default

#if os(iOS) || os(watchOS) || os(tvOS)
notificationCenter.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
#elseif os(macOS)
notificationCenter.removeObserver(self, name: NSApplication.willBecomeActiveNotification, object: nil)
#endif
}

/// When the app enter foreground refresh the assignments or
/// start the timer
///
@objc private func applicationWillEnterForeground() {
refreshIfNeeded()
}
}
6 changes: 2 additions & 4 deletions Automattic-Tracks-iOS/Services/TracksService.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ - (void)switchToAuthenticatedUserWithUsername:(NSString *)username userID:(NSStr
self.token = token;

#if TARGET_OS_IPHONE
// Temporarily uses wpcom while we test that the implementation is not biased
[ExPlat configureWithPlatform:@"wpcom" oAuthToken:token userAgent:self.userAgent anonId:nil];
[ExPlat configureWithPlatform:_eventNamePrefix oAuthToken:token userAgent:self.userAgent anonId:nil];
#endif
}

Expand All @@ -227,8 +226,7 @@ - (void)switchToAnonymousUserWithAnonymousID:(NSString *)anonymousID
self.token = nil;

#if TARGET_OS_IPHONE
// Temporarily uses wpcom while we test that the implementation is not biased
[ExPlat configureWithPlatform:@"wpcom" oAuthToken:nil userAgent:self.userAgent anonId:anonymousID];
[ExPlat configureWithPlatform:_eventNamePrefix oAuthToken:nil userAgent:self.userAgent anonId:anonymousID];
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Automattic-Tracks-iOS/TracksConstants.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "TracksConstants.h"

NSString *const TracksErrorDomain = @"TracksErrorDomain";
NSString *const TracksLibraryVersion = @"0.8.2";
NSString *const TracksLibraryVersion = @"0.8.3";