Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
username0x0a committed Feb 11, 2019
2 parents a84d1a9 + e6f9d02 commit 647ed95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions TravelKit.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |spec|
spec.name = 'TravelKit'
spec.version = '2.0.2'
spec.version = '2.0.3'
spec.license = 'MIT'
spec.homepage = 'https://github.com/sygic-travel/apple-sdk'
spec.authors = 'Tripomatic s.r.o.', 'Michal Zelinka'
spec.summary = 'Travel SDK for travelling projects'
spec.source = { :http => 'https://github.com/sygic-travel/apple-sdk/releases/download/v2.0.2/TravelKit-2.0.2-iOS.zip' }
spec.source = { :http => 'https://github.com/sygic-travel/apple-sdk/releases/download/v2.0.3/TravelKit-2.0.3-iOS.zip' }
spec.documentation_url = 'http://docs.sygictravelapi.com/apple-sdk/latest'
spec.module_name = 'TravelKit'

Expand Down
8 changes: 4 additions & 4 deletions TravelKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,8 @@
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TARGETED_DEVICE_FAMILY = "1,2";
TK_BUNDLE_BUILD = 237;
TK_BUNDLE_VERSION = 2.0.2;
TK_BUNDLE_BUILD = 238;
TK_BUNDLE_VERSION = 2.0.3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1340,8 +1340,8 @@
RUN_CLANG_STATIC_ANALYZER = YES;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
TK_BUNDLE_BUILD = 237;
TK_BUNDLE_VERSION = 2.0.2;
TK_BUNDLE_BUILD = 238;
TK_BUNDLE_VERSION = 2.0.3;
TVOS_DEPLOYMENT_TARGET = 9.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
20 changes: 16 additions & 4 deletions TravelKit/TKSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2017 Tripomatic. All rights reserved.
//

#import <pthread/pthread.h>

#import "TKSessionManager+Private.h"
#import "TKDatabaseManager+Private.h"
#import "TKEventsManager+Private.h"
Expand Down Expand Up @@ -49,13 +51,13 @@ - (instancetype)init
{
__weak typeof(self) weakSelf = self;

_database = [TKDatabaseManager sharedManager];
_events = [TKEventsManager sharedManager];

_events.sessionExpirationHandler = ^{
[weakSelf refreshSession];
};

_database = [TKDatabaseManager sharedManager];
_events = [TKEventsManager sharedManager];

NSString *suiteName = @"com.tripomatic.travelkit";

NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
Expand All @@ -73,7 +75,9 @@ - (instancetype)init

[self loadState];

[self checkSession];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self checkSession];
}];
}

return self;
Expand Down Expand Up @@ -182,20 +186,28 @@ - (void)checkSession

- (void)refreshSession
{
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

if (pthread_mutex_trylock(&lock) != EXIT_SUCCESS)
return;

NSString *token = _session.refreshToken;

if (!token) return;

[[TKSSOAPI sharedAPI] performSessionRefreshWithToken:token success:^(TKSession *session) {

self.session = session;
pthread_mutex_unlock(&lock);

} failure:^(TKAPIError *error) {

// TODO: More sophisticated solution?
if (error.code / 100 == 4)
self.session = nil;

pthread_mutex_unlock(&lock);

}];
}

Expand Down

0 comments on commit 647ed95

Please sign in to comment.