Skip to content

Commit 8f91652

Browse files
Merge branch 'master' into objcNotificationCenter
2 parents 3837278 + 400e49d commit 8f91652

File tree

12 files changed

+528
-128
lines changed

12 files changed

+528
-128
lines changed

DemoObjCApp/AppDelegate.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5151

5252
-(void)initializeOptimizelySDKAsynchronous {
5353
self.optimizely = [[OptimizelyManager alloc] initWithSdkKey:kOptimizelySdkKey];
54-
55-
[self.optimizely initializeSDKWithCompletion:^(NSError * _Nullable error, NSData * _Nullable data) {
54+
55+
[self.optimizely initializeSDKWithCompletion:^(NSData * _Nullable data, NSError * _Nullable error) {
5656
if (error == nil) {
5757
NSLog(@"Optimizely SDK initialized successfully!");
5858
} else {
@@ -111,7 +111,7 @@ -(void)startAppWithExperimentActivated {
111111
NSLog(@"Optimizely SDK activation failed: %@", error.localizedDescription);
112112
self.optimizely = nil;
113113
}
114-
114+
115115

116116
[self setRootViewControllerWithOtimizelyManager:self.optimizely bucketedVariation:variationKey];
117117
}

DemoObjCApp/VariationViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ - (IBAction)unwindToVariationAction:(UIStoryboardSegue *)segue {
4040

4141
- (IBAction)attemptTrackAndShowSuccessOrFailure:(id)sender {
4242
NSError *error;
43+
4344
BOOL status = [self.optimizely trackWithEventKey:self.eventKey userId:self.userId attributes:nil eventTags:nil error:&error];
4445

4546
if (status) {

DemoSwiftApp/AppDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6767
logger: customLogger,
6868
periodicDownloadInterval:30)
6969

70-
7170
_ = optimizely?.notificationCenter.addDatafileChangeNotificationListener(datafileListener: { (data) in
7271
DispatchQueue.main.async {
7372
#if os(iOS)
@@ -149,7 +148,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
149148
userId: userId,
150149
attributes: attributes)
151150
openVariationView(optimizelyManager: optimizely, variationKey: variationKey)
152-
153151
// used to test threading and datafile updates.
154152
//
155153
// DispatchQueue.global(qos: .background).async {

OptimizelySDK/Customization/DefaultEventDispatcher.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ open class DefaultEventDispatcher : BackgroundingCallbacks, OPTEventDispatcher {
194194
self.logger?.log(level: .debug, message: response.debugDescription)
195195

196196
if let error = error {
197-
completionHandler(Result.failure(OPTEventDispatchError(description: error.localizedDescription)))
197+
completionHandler(.failure(.eventDispatchFailed(error.localizedDescription)))
198198
}
199199
else {
200200
self.logger?.log(level: .debug, message: "Event Sent")
201-
completionHandler(Result.success(event.body))
201+
completionHandler(.success(event.body))
202202
}
203203
}
204204

OptimizelySDK/Customization/Protocols/OPTEventDispatcher.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@
1616

1717
import Foundation
1818

19-
public typealias DispatchCompletionHandler = (Result<Data, OPTEventDispatchError>)->(Void)
20-
21-
public class OPTEventDispatchError : Error {
22-
public var localizedDescription: String
23-
24-
init(description:String) {
25-
localizedDescription = description
26-
}
27-
}
19+
public typealias DispatchCompletionHandler = (Result<Data, OptimizelyError>)->(Void)
2820

2921
/**
3022
The OPTEventDispatcher dispatches events to the Optimizely backend used in results.

OptimizelySDK/Customization/Protocols/OPTLogger.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212
/**
1313
* Any logger must implement these following methods.
1414
*/
15-
public protocol OPTLogger {
15+
@objc public protocol OPTLogger {
1616

1717
/// The log level the Logger is initialized with.
1818
static var logLevel: OptimizelyLogLevel { get set }

OptimizelySDK/Customization/Protocols/OPTUserProfileService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct UserProfileKeys {
7979
static let kUserId = "user_id"
8080
}
8181

82-
public protocol OPTUserProfileService {
82+
@objc public protocol OPTUserProfileService {
8383

8484
typealias UPProfile = [String: Any] // {"experiment_bucket_map", "user_id"}
8585
typealias UPBucketMap = [String: UPExperimentMap]

OptimizelySDK/Data Model/DispatchEvents/EventForDispatch.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@
88

99
import Foundation
1010

11-
public class EventForDispatch : Equatable, Codable {
11+
@objcMembers public class EventForDispatch: NSObject, Codable {
1212
static let eventEndpoint = "https://logx.optimizely.com/v1/events"
1313

14-
public let url:URL
15-
public let body:Data
16-
17-
init(url: URL? = nil, body: Data) {
14+
public let url: URL
15+
public let body: Data
16+
17+
public init(url: URL? = nil, body: Data) {
1818
self.url = url ?? URL(string: EventForDispatch.eventEndpoint)!
1919
self.body = body
2020
}
21+
22+
// override NSObject Equatable ('==' overriding not working for NSObject)
23+
override public func isEqual(_ object: Any?) -> Bool {
24+
guard let object = object as? EventForDispatch else { return false }
25+
return url == object.url && body == object.body
26+
}
2127
}

0 commit comments

Comments
 (0)