File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
58
58
// MARK: - Initialization Examples
59
59
60
60
-(void )initializeOptimizelySDKAsynchronous {
61
- self.optimizely = [[OptimizelyClient alloc ] initWithSdkKey: kOptimizelySdkKey ];
61
+ DefaultEventDispatcher *eventDispacher = [[DefaultEventDispatcher alloc ] initWithTimerInterval: 1 ];
62
+
63
+ self.optimizely = [[OptimizelyClient alloc ] initWithSdkKey: kOptimizelySdkKey logger: nil eventDispatcher: eventDispacher userProfileService: nil periodicDownloadInterval: @(5 ) defaultLogLevel: OptimizelyLogLevelDebug];
62
64
63
65
[self .optimizely startWithCompletion: ^(NSData *data, NSError *error) {
64
66
if (error == nil ) {
Original file line number Diff line number Diff line change @@ -433,10 +433,38 @@ extension OptimizelyClient {
433
433
}
434
434
435
435
// MARK: - ObjC protocols
436
-
437
436
@objc ( OPTEventDispatcher) public protocol _ObjcOPTEventDispatcher {
438
437
func dispatchEvent( event: EventForDispatch , completionHandler: ( ( Data ? , NSError ? ) -> Void ) ? )
439
438
440
439
/// Attempts to flush the event queue if there are any events to process.
441
440
func flushEvents( )
442
441
}
442
+
443
+ @available ( swift, obsoleted: 1.0 )
444
+ @objc ( DefaultEventDispatcher) public class ObjEventDispatcher : NSObject , _ObjcOPTEventDispatcher {
445
+
446
+ let innerEventDispatcher : DefaultEventDispatcher
447
+
448
+ @objc public init ( timerInterval: TimeInterval ) {
449
+ innerEventDispatcher = DefaultEventDispatcher ( timerInterval: timerInterval)
450
+ }
451
+
452
+ public func dispatchEvent( event: EventForDispatch , completionHandler: ( ( Data ? , NSError ? ) -> Void ) ? ) {
453
+ innerEventDispatcher. dispatchEvent ( event: event) { ( result) -> ( Void ) in
454
+ guard let completionHandler = completionHandler else { return }
455
+
456
+ switch result {
457
+ case . success( let value) :
458
+ completionHandler ( value, nil )
459
+ case . failure( let error) :
460
+ completionHandler ( nil , error as NSError )
461
+ }
462
+ }
463
+ }
464
+
465
+ public func flushEvents( ) {
466
+ innerEventDispatcher. flushEvents ( )
467
+ }
468
+
469
+
470
+ }
You can’t perform that action at this time.
0 commit comments