Skip to content

Commit

Permalink
Preparing release 3.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
queue-it committed Oct 20, 2021
1 parent 786baee commit 73d8271
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ QueueITLib.xcworkspace/xcuserdata/queut-it.xcuserdatad/xcdebugger/**
QueueITLib.xcworkspace/xcuserdata
QueueITLib.xcworkspace
builds
xcuserdata/
xcuserdata/
/.idea
1 change: 1 addition & 0 deletions QueueITLib/IOSUtils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <Foundation/Foundation.h>
#import "QueueConsts.h"

@interface IOSUtils : NSObject
+(NSString*)getUserId;
Expand Down
2 changes: 1 addition & 1 deletion QueueITLib/IOSUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ +(NSString*)getLibraryVersion{
}

+(NSString*)getSdkVersion{
return @"iOS-3.0.7";
return SDKVersion;
}

@end
2 changes: 2 additions & 0 deletions QueueITLib/QueueConsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
#define QueueConsts_h

#define QueueCloseUrl @"queueit://close"
#define QueueRestartSessionUrl @"queueit://restartSession"
#define SDKVersion @"iOS-3.0.8";

#endif
29 changes: 20 additions & 9 deletions QueueITLib/QueueITEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@protocol QueueITUnavailableDelegate;
@protocol QueueUserExitedDelegate;
@protocol QueueViewClosedDelegate;
@protocol QueueSessionRestartDelegate;

@interface QueueITEngine : NSObject
@property (nonatomic)id<QueuePassedDelegate> queuePassedDelegate;
Expand All @@ -16,6 +17,7 @@
@property (nonatomic)id<QueueITUnavailableDelegate> queueITUnavailableDelegate;
@property (nonatomic)id<QueueUserExitedDelegate> queueUserExitedDelegate;
@property (nonatomic)id<QueueViewClosedDelegate> queueViewClosedDelegate;
@property (nonatomic)id<QueueSessionRestartDelegate> queueSessionRestartDelegate;
@property (nonatomic, strong)NSString* errorMessage;

typedef enum {
Expand All @@ -32,24 +34,33 @@ typedef enum {

-(void)setViewDelay:(int)delayInterval;
-(BOOL)run:(NSError **)error;
-(void)raiseQueuePassed:(NSString*) queueitToken;
-(BOOL)runWithEnqueueToken:(NSString*) enqueueToken
error:(NSError **) error;
-(BOOL)runWithEnqueueKey:(NSString*) enqueueKey
error:(NSError **) error;
-(BOOL)isUserInQueue;
-(BOOL)isRequestInProgress;
-(NSString*) errorTypeEnumToString:(QueueITRuntimeError)errorEnumVal;
-(void)raiseUserExited;
-(void)updateQueuePageUrl:(NSString*)queuePageUrl;
-(void)raiseUserExited;
-(void)raiseViewClosed;
-(void)close: (void (^ __nullable)(void))onComplete;
-(void)handleAppEnqueueResponse:(NSString*) queueId
queueURL:(NSString*) queueURL
-(void)raiseSessionRestart;
-(void)raiseQueuePassed:(NSString*) queueitToken;
-(void)close:(void (^ __nullable)(void))onComplete;
-(void)handleAppEnqueueResponse:(NSString* _Nullable) queueId
queueURL:(NSString* _Nullable) queueURL
queueURLTTLInMinutes:(int) ttl
eventTargetURL:(NSString*) targetURL
queueItToken:(NSString*) token;
eventTargetURL:(NSString* _Nullable) targetURL
queueItToken:(NSString* _Nullable) token;

@end

@protocol QueuePassedDelegate <NSObject>
-(void)notifyYourTurn:(QueuePassedInfo*) queuePassedInfo;
-(void)notifyYourTurn:(QueuePassedInfo* _Nullable) queuePassedInfo;
@end

@protocol QueueSessionRestartDelegate <NSObject>
-(void)notifySessionRestart;
@end

@protocol QueueViewWillOpenDelegate <NSObject>
Expand All @@ -61,7 +72,7 @@ typedef enum {
@end

@protocol QueueITUnavailableDelegate <NSObject>
-(void)notifyQueueITUnavailable: (NSString *) errorMessage;
-(void)notifyQueueITUnavailable:(NSString *) errorMessage;
@end

@protocol QueueUserExitedDelegate <NSObject>
Expand Down
88 changes: 61 additions & 27 deletions QueueITLib/QueueITEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ -(instancetype)initWithHost:(UIViewController *)host customerId:(NSString*)custo
return self;
}

-(void)close: (void (^ __nullable)(void))onComplete
-(void)close:(void (^ __nullable)(void))onComplete
{
NSLog(@"Closing webview");
if(currentWebView!=nil){
Expand Down Expand Up @@ -94,7 +94,26 @@ -(BOOL)isRequestInProgress {
return self.requestInProgress;
}

-(BOOL)runWithEnqueueKey:(NSString *)enqueueKey
error:(NSError *__autoreleasing *)error
{
return [self runWithParameters:nil enqueueKey:enqueueKey error:error];
}

-(BOOL)runWithEnqueueToken:(NSString *)enqueueToken
error:(NSError *__autoreleasing *)error
{
return [self runWithParameters:enqueueToken enqueueKey:nil error:error];
}

-(BOOL)run:(NSError **)error
{
return [self runWithParameters:nil enqueueKey:nil error:error];
}

-(BOOL)runWithParameters:(NSString*)enqueueToken
enqueueKey:(NSString*)enqueueKey
error:(NSError**)error
{
if(![self checkConnection:error]){
return NO;
Expand All @@ -109,7 +128,7 @@ -(BOOL)run:(NSError **)error
self.requestInProgress = YES;

if (![self tryShowQueueFromCache]) {
[self tryEnqueue];
[self tryEnqueue:enqueueToken enqueueKey:enqueueKey];
}

return YES;
Expand Down Expand Up @@ -138,11 +157,11 @@ -(void)showQueue:(NSString*)queueUrl targetUrl:(NSString*)targetUrl
[self raiseQueueViewWillOpen];

QueueITWKViewController *queueWKVC = [[QueueITWKViewController alloc] initWithHost:self.host
queueEngine:self
queueUrl:queueUrl
eventTargetUrl:targetUrl
customerId:self.customerId
eventId:self.eventId];
queueEngine:self
queueUrl:queueUrl
eventTargetUrl:targetUrl
customerId:self.customerId
eventId:self.eventId];
currentWebView = queueWKVC;

if (@available(iOS 13.0, *)) {
Expand All @@ -159,10 +178,11 @@ -(void)showQueue:(NSString*)queueUrl targetUrl:(NSString*)targetUrl
}
}

-(void)tryEnqueue
-(void)tryEnqueue:(NSString*)enqueueToken
enqueueKey:(NSString*)enqueueKey
{
[IOSUtils getUserAgent:^(NSString * userAgent) {
[self tryEnqueueWithUserAgent:userAgent];
[self tryEnqueueWithUserAgent:userAgent enqueueToken:enqueueToken enqueueKey:enqueueKey];
}];
}

Expand Down Expand Up @@ -211,6 +231,8 @@ -(void)handleAppEnqueueResponse:(NSString*) queueId
}

-(void)tryEnqueueWithUserAgent:(NSString*)secretAgent
enqueueToken:(NSString*)enqueueToken
enqueueKey:(NSString*)enqueueKey
{
NSString* userId = [IOSUtils getUserId];
NSString* userAgent = [NSString stringWithFormat:@"%@;%@", secretAgent, [IOSUtils getLibraryVersion]];
Expand All @@ -219,41 +241,45 @@ -(void)tryEnqueueWithUserAgent:(NSString*)secretAgent
QueueService* qs = [QueueService sharedInstance];
[qs enqueue:self.customerId
eventOrAliasId:self.eventId
userId:userId userAgent:userAgent
userId:userId
userAgent:userAgent
sdkVersion:sdkVersion
layoutName:self.layoutName
language:self.language
enqueueToken:enqueueToken
enqueueKey:enqueueKey
success:^(QueueStatus *queueStatus)
{
if (queueStatus == NULL) {
[self enqueueRetryMonitor];
return;
}
if (queueStatus == NULL) {
[self enqueueRetryMonitor:enqueueToken enqueueKey:enqueueKey];
return;
}

[self handleAppEnqueueResponse: queueStatus.queueId
queueURL:queueStatus.queueUrlString
queueURLTTLInMinutes:queueStatus.queueUrlTTL
eventTargetURL:queueStatus.eventTargetUrl
queueItToken:queueStatus.queueitToken];
}
}
failure:^(NSError *error, NSString* errorMessage)
{
if (error.code >= 400 && error.code < 500)
{
[self.queueITUnavailableDelegate notifyQueueITUnavailable: errorMessage];
}
else
{
[self enqueueRetryMonitor];
}
}];
if (error.code >= 400 && error.code < 500)
{
[self.queueITUnavailableDelegate notifyQueueITUnavailable: errorMessage];
}
else
{
[self enqueueRetryMonitor:enqueueToken enqueueKey:enqueueKey];
}
}];
}

-(void)enqueueRetryMonitor
-(void)enqueueRetryMonitor:(NSString*)enqueueToken
enqueueKey:(NSString*)enqueueKey
{
if (self.deltaSec < MAX_RETRY_SEC)
{
[self tryEnqueue];
[self tryEnqueue:enqueueToken enqueueKey:enqueueKey];

[NSThread sleepForTimeInterval:self.deltaSec];
self.deltaSec = self.deltaSec * 2;
Expand Down Expand Up @@ -299,8 +325,16 @@ -(void) raiseQueueDisabled
[self.queueDisabledDelegate notifyQueueDisabled];
}

-(void) raiseSessionRestart
{
self.requestInProgress = NO;
[self.cache clear];
[self.queueSessionRestartDelegate notifySessionRestart];
}

-(void) raiseViewClosed
{
self.requestInProgress = NO;
[self.queueViewClosedDelegate notifyViewClosed];
}

Expand Down
5 changes: 2 additions & 3 deletions QueueITLib/QueueITWKViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
customerId:(nonnull NSString*)customerId
eventId:(nonnull NSString*)eventId;

- (void)close: (void (^ __nullable)(void))completion;
- (void)close:(void (^ __nullable)(void))completion;

- (BOOL)handleSpecialUrls:(nonnull NSURL*) url
decisionHandler:(nonnull void (^)(WKNavigationActionPolicy))decisionHandler;
Expand All @@ -20,5 +20,4 @@

- (BOOL) isBlockedUrl:(nonnull NSURL*) destinationUrl;

@end

@end
8 changes: 7 additions & 1 deletion QueueITLib/QueueITWKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ -(instancetype)initWithHost:(UIViewController *)host
return self;
}

- (void)close: (void (^ __nullable)(void))onComplete {
- (void)close:(void (^ __nullable)(void))onComplete {
[self.host dismissViewControllerAnimated:YES completion:^{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
if(onComplete!=nil){
Expand Down Expand Up @@ -73,6 +73,12 @@ - (BOOL)handleSpecialUrls:(NSURL*) url
}];
decisionHandler(WKNavigationActionPolicyCancel);
return true;
} else if ([[url absoluteString] isEqualToString: QueueRestartSessionUrl]){
[self close:^{
[self.engine raiseSessionRestart];
}];
decisionHandler(WKNavigationActionPolicyCancel);
return true;
}
return NO;
}
Expand Down
2 changes: 1 addition & 1 deletion QueueITLib/QueuePassedInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

@property (nonatomic, strong) NSString* queueitToken;

-(instancetype)initWithQueueitToken: (NSString*) queueitToken;
-(instancetype)initWithQueueitToken:(NSString*) queueitToken;

@end
3 changes: 2 additions & 1 deletion QueueITLib/QueueService.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ typedef void (^QueueServiceFailure)(NSError *error, NSString* errorMessage);
sdkVersion:(NSString*)sdkVersion
layoutName:(NSString*)layoutName
language:(NSString*)language
enqueueToken:(NSString*)enqueueToken
enqueueKey:(NSString*)enqueueKey
success:(void(^)(QueueStatus* queueStatus))success
failure:(QueueServiceFailure)failure;


@end
Loading

0 comments on commit 73d8271

Please sign in to comment.