Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-11-15 18:47:14 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a25e28688651c58c34b27a7c73a28d23efb69fca
a25e2868
1 parent
71c921ee
fix db select crash
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
21 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
a25e286
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
View file @
a25e286
...
...
@@ -697,12 +697,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
[
self
createDBIfNeeded
];
[
self
initDBIfNeeded
];
[
self
restore
];
NSString
*
accessToken
=
[
NSString
alloc
];
// NSString *accessToken = [NSString alloc];
NSString
*
accessToken
=
@""
;
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
@try
{
FMResultSet
*
accessTokenSet
=
[
_db
executeQuery
:
@"SELECT access_token FROM requestVariables WHERE id = 1;"
];
while
([
accessTokenSet
next
])
{
accessToken
=
[[
accessTokenSet
resultDictionary
][
@"access_token"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT accessToken error: %@"
,
exception
.
reason
);
}
@finally
{
// NSLog(@"Finally condition");
}
// FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
// while ([accessTokenSet next]) {
// accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
// }
return
accessToken
;
}
return
@""
;
...
...
@@ -1069,24 +1083,40 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
-
(
void
)
refreshToken
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = [NSString alloc];
NSString
*
refreshToken
=
@""
;
NSString
*
clientId
=
@""
;
NSString
*
clientSecret
=
@""
;
@try
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = @"";
while
([
refreshTokenSet
next
])
{
refreshToken
=
[[
refreshTokenSet
resultDictionary
][
@"refresh_token"
]
stringValue
];
}
FMResultSet
*
clientIdSet
=
[
_db
executeQuery
:
@"SELECT client_id FROM requestVariables WHERE id = 1;"
];
// NSString *clientId = [NSString alloc];
NSString
*
clientId
=
@""
;
// NSString *clientId = [NSString alloc];
//
NSString *clientId = @"";
while
([
clientIdSet
next
])
{
clientId
=
[[
clientIdSet
resultDictionary
][
@"client_id"
]
stringValue
];
}
FMResultSet
*
clientSecretSet
=
[
_db
executeQuery
:
@"SELECT client_secret FROM requestVariables WHERE id = 1;"
];
// NSString *clientSecret = [NSString alloc];
NSString
*
clientSecret
=
@""
;
// NSString *clientSecret = [NSString alloc];
//
NSString *clientSecret = @"";
while
([
clientSecretSet
next
])
{
clientSecret
=
[[
clientSecretSet
resultDictionary
][
@"client_secret"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT Token error: %@"
,
exception
.
reason
);
if
(
failure
)
{
NSError
*
error
=
nil
;
failure
(
error
);
}
}
@finally
{
// NSLog(@"Finally condition");
}
NSDictionary
*
postDictionary3
=
@{
@"client_id"
:
clientId
,
@"client_secret"
:
clientSecret
,
@"refresh_token"
:
refreshToken
,
@"grant_type"
:
@"refresh_token"
,
};
NSData
*
jsonData3
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary3
options
:
0
error
:
NULL
];
...
...
@@ -1125,24 +1155,39 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
-
(
void
)
refreshToken2ndTry
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = [NSString alloc];
NSString
*
refreshToken
=
@""
;
NSString
*
clientId
=
@""
;
NSString
*
clientSecret
=
@""
;
@try
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = @"";
while
([
refreshTokenSet
next
])
{
refreshToken
=
[[
refreshTokenSet
resultDictionary
][
@"refresh_token"
]
stringValue
];
}
FMResultSet
*
clientIdSet
=
[
_db
executeQuery
:
@"SELECT client_id FROM requestVariables WHERE id = 1;"
];
// NSString *clientId = [NSString alloc];
NSString
*
clientId
=
@""
;
// NSString *clientId = [NSString alloc];
//
NSString *clientId = @"";
while
([
clientIdSet
next
])
{
clientId
=
[[
clientIdSet
resultDictionary
][
@"client_id"
]
stringValue
];
}
FMResultSet
*
clientSecretSet
=
[
_db
executeQuery
:
@"SELECT client_secret FROM requestVariables WHERE id = 1;"
];
// NSString *clientSecret = [NSString alloc];
NSString
*
clientSecret
=
@""
;
// NSString *clientSecret = [NSString alloc];
//
NSString *clientSecret = @"";
while
([
clientSecretSet
next
])
{
clientSecret
=
[[
clientSecretSet
resultDictionary
][
@"client_secret"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT Token error: %@"
,
exception
.
reason
);
if
(
failure
)
{
NSError
*
error
=
nil
;
failure
(
error
);
}
}
@finally
{
// NSLog(@"Finally condition");
}
NSDictionary
*
postDictionary3
=
@{
@"client_id"
:
clientId
,
@"client_secret"
:
clientSecret
,
@"refresh_token"
:
refreshToken
,
@"grant_type"
:
@"refresh_token"
,
};
NSData
*
jsonData3
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary3
options
:
0
error
:
NULL
];
...
...
@@ -1181,24 +1226,39 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
-
(
void
)
refreshToken3rdTry
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = [NSString alloc];
NSString
*
refreshToken
=
@""
;
NSString
*
clientId
=
@""
;
NSString
*
clientSecret
=
@""
;
@try
{
FMResultSet
*
refreshTokenSet
=
[
_db
executeQuery
:
@"SELECT refresh_token FROM requestVariables WHERE id = 1;"
];
// NSString *refreshToken = @"";
while
([
refreshTokenSet
next
])
{
refreshToken
=
[[
refreshTokenSet
resultDictionary
][
@"refresh_token"
]
stringValue
];
}
FMResultSet
*
clientIdSet
=
[
_db
executeQuery
:
@"SELECT client_id FROM requestVariables WHERE id = 1;"
];
// NSString *clientId = [NSString alloc];
NSString
*
clientId
=
@""
;
// NSString *clientId = [NSString alloc];
//
NSString *clientId = @"";
while
([
clientIdSet
next
])
{
clientId
=
[[
clientIdSet
resultDictionary
][
@"client_id"
]
stringValue
];
}
FMResultSet
*
clientSecretSet
=
[
_db
executeQuery
:
@"SELECT client_secret FROM requestVariables WHERE id = 1;"
];
// NSString *clientSecret = [NSString alloc];
NSString
*
clientSecret
=
@""
;
// NSString *clientSecret = [NSString alloc];
//
NSString *clientSecret = @"";
while
([
clientSecretSet
next
])
{
clientSecret
=
[[
clientSecretSet
resultDictionary
][
@"client_secret"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT Token error: %@"
,
exception
.
reason
);
if
(
failure
)
{
NSError
*
error
=
nil
;
failure
(
error
);
}
}
@finally
{
// NSLog(@"Finally condition");
}
NSDictionary
*
postDictionary3
=
@{
@"client_id"
:
clientId
,
@"client_secret"
:
clientSecret
,
@"refresh_token"
:
refreshToken
,
@"grant_type"
:
@"refresh_token"
,
};
NSData
*
jsonData3
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary3
options
:
0
error
:
NULL
];
...
...
@@ -4526,12 +4586,29 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
//Set HTTP Headers
time_t
timestamp
=
(
time_t
)
[[
NSDate
date
]
timeIntervalSince1970
];
NSString
*
accessToken
=
[
NSString
alloc
];
// NSString *accessToken = [NSString alloc];
NSString
*
accessToken
=
@""
;
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
// FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
// while ([accessTokenSet next]) {
// accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
// }
@try
{
FMResultSet
*
accessTokenSet
=
[
_db
executeQuery
:
@"SELECT access_token FROM requestVariables WHERE id = 1;"
];
while
([
accessTokenSet
next
])
{
accessToken
=
[[
accessTokenSet
resultDictionary
][
@"access_token"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT accessToken error: %@"
,
exception
.
reason
);
if
(
failureBlock
)
{
NSError
*
error
=
nil
;
failureBlock
(
error
);
}
}
@finally
{
// NSLog(@"Finally condition");
}
[
_httpClient
.
requestSerializer
setValue
:[
@"Bearer "
stringByAppendingString
:
accessToken
]
forHTTPHeaderField
:
@"Authorization"
];
}
[
_httpClient
.
requestSerializer
setValue
:
_webId
forHTTPHeaderField
:
@"loyalty-web-id"
];
...
...
@@ -4665,12 +4742,29 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
//Set HTTP Headers
time_t
timestamp
=
(
time_t
)
[[
NSDate
date
]
timeIntervalSince1970
];
NSString
*
accessToken
=
[
NSString
alloc
];
// NSString *accessToken = [NSString alloc];
NSString
*
accessToken
=
@""
;
if
([
_db
tableExists
:
@"requestVariables"
]
==
YES
)
{
@try
{
FMResultSet
*
accessTokenSet
=
[
_db
executeQuery
:
@"SELECT access_token FROM requestVariables WHERE id = 1;"
];
while
([
accessTokenSet
next
])
{
accessToken
=
[[
accessTokenSet
resultDictionary
][
@"access_token"
]
stringValue
];
}
}
@catch
(
NSException
*
exception
)
{
NSLog
(
@"SELECT accessToken error: %@"
,
exception
.
reason
);
if
(
failureBlock
)
{
NSError
*
error
=
nil
;
failureBlock
(
error
);
}
}
@finally
{
// NSLog(@"Finally condition");
}
// FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
// while ([accessTokenSet next]) {
// accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
// }
[
_httpClient
.
requestSerializer
setValue
:[
@"Bearer "
stringByAppendingString
:
accessToken
]
forHTTPHeaderField
:
@"Authorization"
];
}
[
_httpClient
.
requestSerializer
setValue
:
_webId
forHTTPHeaderField
:
@"loyalty-web-id"
];
...
...
Please
register
or
login
to post a comment