Skip to content

Commit

Permalink
Added launch synchronously API
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaunteya Suryawanshi committed May 31, 2018
1 parent 08822d4 commit 8811525
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 11 additions & 2 deletions VWO/VWO.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,32 @@ __deprecated_msg("Use launchForAPIKey:config:completion:failure instead");
failure:(nullable void (^)(NSString *error))failureBlock
NS_SWIFT_NAME(launch(apiKey:config:completion:failure:));

+ (void)launchSynchronouslyForAPIKey:(NSString *)apiKey
timeout:(NSTimeInterval)timeout
NS_SWIFT_NAME(launchSynchronously(apiKey:timeout:))
__deprecated_msg("Use launchSynchronouslyForAPIKey:config:timeout");


/**
`Synchronously` fetch campaign settings
This method is typically invoked in your application:didFinishLaunchingWithOptions: method.
@param apiKey Unique developer ApiKey provided by VWO.
@param config Launch configuration
@param timeout Request timeout
@warning Use of this method should be avoided as it blocks the main thread, which would freeze your UI.
@see launchForAPIKey:
*/

+ (void)launchSynchronouslyForAPIKey:(NSString *)apiKey
config:(nullable VWOConfig *)config
timeout:(NSTimeInterval)timeout
NS_SWIFT_NAME(launchSynchronously(apiKey:timeout:))
__deprecated_msg("Use launchForAPIKey:config:completion:failure instead");
NS_SWIFT_NAME(launchSynchronously(apiKey:config:timeout:));


+ (nullable id)variationForKey:(NSString *)key
Expand Down
14 changes: 14 additions & 0 deletions VWO/VWO.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ + (void)launchSynchronouslyForAPIKey:(NSString *)apiKey
});
}

+ (void)launchSynchronouslyForAPIKey:(NSString *)apiKey
config:(nullable VWOConfig *)config
timeout:(NSTimeInterval)timeout {
NSParameterAssert(apiKey);
dispatch_barrier_sync(VWOController.taskQueue, ^{
[VWOController.shared launchWithAPIKey:apiKey
config:config
withTimeout:@(timeout)
withCallback:nil
failure:nil];

});
}

+ (void)launchSynchronouslyForAPIKey:(NSString *)apiKey
timeout:(NSTimeInterval)timeout
config:(VWOConfig *)config {
Expand Down

0 comments on commit 8811525

Please sign in to comment.