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 @@ -55,7 +55,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5555// MARK: - Initialization Examples
5656
5757-(void )initializeOptimizelySDKAsynchronous {
58- self.optimizely = [[OptimizelyClient alloc ] initWithSdkKey: kOptimizelySdkKey ];
58+ DefaultEventDispatcher *eventDispacher = [[DefaultEventDispatcher alloc ] initWithTimerInterval: 1 ];
59+
60+ self.optimizely = [[OptimizelyClient alloc ] initWithSdkKey: kOptimizelySdkKey logger: nil eventDispatcher: eventDispacher userProfileService: nil periodicDownloadInterval: @(5 ) defaultLogLevel: OptimizelyLogLevelDebug];
5961
6062 [self .optimizely startWithCompletion: ^(NSData *data, NSError *error) {
6163 if (error == nil ) {
Original file line number Diff line number Diff line change @@ -433,10 +433,38 @@ extension OptimizelyClient {
433433}
434434
435435// MARK: - ObjC protocols
436-
437436@objc ( OPTEventDispatcher) public protocol _ObjcOPTEventDispatcher {
438437 func dispatchEvent( event: EventForDispatch , completionHandler: ( ( Data ? , NSError ? ) -> Void ) ? )
439438
440439 /// Attempts to flush the event queue if there are any events to process.
441440 func flushEvents( )
442441}
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