- Add JsonRequestSearilizer and HttpRequestSerializer
This commit is contained in:
parent
7f8b1e9864
commit
8dc43751be
@ -40,7 +40,7 @@ PODS:
|
||||
- NSString-Helper (1.0.3)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.3.13):
|
||||
- PNObject (0.3.14):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- FBSDKCoreKit
|
||||
@ -96,7 +96,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: d4c5459e8142ee6a96b070118009f08637030c2d
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: 7e0d02a6de46f9b8d72859bee9088c260c5ae078
|
||||
PNObject: cf403a77375ff20dba304d04eb79892fdae3d54d
|
||||
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
|
||||
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "PNObject",
|
||||
"version": "0.3.13",
|
||||
"version": "0.3.14",
|
||||
"summary": "PNObject is a simple replica of the more complex ParseObject",
|
||||
"homepage": "https://github.com/giuseppenucifora/PNObject",
|
||||
"license": "MIT",
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"source": {
|
||||
"git": "https://github.com/giuseppenucifora/PNObject.git",
|
||||
"tag": "0.3.13"
|
||||
"tag": "0.3.14"
|
||||
},
|
||||
"platforms": {
|
||||
"ios": "7.0"
|
||||
|
||||
4
Example/Pods/Manifest.lock
generated
4
Example/Pods/Manifest.lock
generated
@ -40,7 +40,7 @@ PODS:
|
||||
- NSString-Helper (1.0.3)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.3.13):
|
||||
- PNObject (0.3.14):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- FBSDKCoreKit
|
||||
@ -96,7 +96,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: d4c5459e8142ee6a96b070118009f08637030c2d
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: 7e0d02a6de46f9b8d72859bee9088c260c5ae078
|
||||
PNObject: cf403a77375ff20dba304d04eb79892fdae3d54d
|
||||
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
|
||||
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.3.13</string>
|
||||
<string>0.3.14</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.3.13</string>
|
||||
<string>0.3.14</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "PNObject"
|
||||
s.version = "0.3.13"
|
||||
s.version = "0.3.14"
|
||||
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
||||
|
||||
if ([[PNObjectConfig sharedInstance] currentOauthCredential] && ![[[PNObjectConfig sharedInstance] currentOauthCredential] isExpired]) {
|
||||
|
||||
[[[PNObjectConfig sharedInstance] manager] setRequestSerializer:[[PNObjectConfig sharedInstance] jsonSerializer]];
|
||||
[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingFormat:@"%@",endPoint] parameters:parameters progress:downloadProgress success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
|
||||
if (success) {
|
||||
|
||||
@ -184,11 +184,22 @@ extern NSString* _Nonnull const Client_Secret;
|
||||
///--------------------------------------
|
||||
#pragma mark - PNObjectConfig Properties
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nonnull) AFOAuth2Manager *manager;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, readonly, nonnull) AFJSONRequestSerializer *jsonSerializer;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, readonly, nonnull) AFHTTPRequestSerializer *httpSerializer;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
|
||||
@ -153,6 +153,9 @@ static bool isFirstAccess = YES;
|
||||
_configuration = [[NSMutableDictionary alloc] init];
|
||||
_minPasswordLenght = minPassLenght;
|
||||
|
||||
_jsonSerializer = [AFJSONRequestSerializer serializer];
|
||||
_httpSerializer = [AFHTTPRequestSerializer serializer];
|
||||
|
||||
_headerFields = [[NSMutableDictionary alloc] init];
|
||||
|
||||
if ([[NSUserDefaults standardUserDefaults] objectForKey:PNObjectEncryptionKey]) {
|
||||
@ -217,13 +220,15 @@ static bool isFirstAccess = YES;
|
||||
|
||||
for (NSString *key in [_headerFields allKeys]) {
|
||||
|
||||
[[_manager requestSerializer] setValue:[_headerFields objectForKey:key] forHTTPHeaderField:key];
|
||||
[_httpSerializer setValue:[_headerFields objectForKey:key] forHTTPHeaderField:key];
|
||||
[_jsonSerializer setValue:[_headerFields objectForKey:key] forHTTPHeaderField:key];
|
||||
}
|
||||
|
||||
if (canTryRefreh) {
|
||||
|
||||
if (_currentOauthCredential && ![_currentOauthCredential isExpired]) {
|
||||
[[_manager requestSerializer] setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_httpSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_jsonSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
}
|
||||
else {
|
||||
[self refreshToken];
|
||||
@ -262,11 +267,14 @@ static bool isFirstAccess = YES;
|
||||
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
||||
|
||||
if([SINGLETON.userSubClass currentUser] && [[SINGLETON.userSubClass currentUser] hasValidEmailAndPasswordData]) {
|
||||
[_manager setRequestSerializer:_httpSerializer];
|
||||
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:[[SINGLETON.userSubClass currentUser] email] password:[[(PNUser*)[SINGLETON.userSubClass currentUser] password] password] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
||||
_currentOauthCredential = credential;
|
||||
|
||||
[AFOAuthCredential storeCredential:_currentOauthCredential withIdentifier:PNObjectServiceCredentialIdentifier];
|
||||
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
//[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_httpSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_jsonSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
|
||||
if (success) {
|
||||
success(YES);
|
||||
@ -307,11 +315,14 @@ static bool isFirstAccess = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
[_manager setRequestSerializer:_httpSerializer];
|
||||
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] username:email password:password scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
||||
_currentOauthCredential = credential;
|
||||
|
||||
[AFOAuthCredential storeCredential:_currentOauthCredential withIdentifier:PNObjectServiceCredentialIdentifier];
|
||||
[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
//[_manager.requestSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_httpSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
[_jsonSerializer setAuthorizationHeaderFieldWithCredential:_currentOauthCredential];
|
||||
|
||||
if (success) {
|
||||
success(YES);
|
||||
@ -333,6 +344,7 @@ static bool isFirstAccess = YES;
|
||||
- (void) refreshTokenForClientCredentialWithBlockSuccess:(nullable void (^)(BOOL refreshSuccess))success
|
||||
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
||||
|
||||
[_manager setRequestSerializer:_httpSerializer];
|
||||
[_manager authenticateUsingOAuthWithURLString:[_currentEndPointBaseUrl stringByAppendingString:@"oauth-token"] scope:nil success:^(AFOAuthCredential * _Nonnull credential) {
|
||||
_currentOauthCredential = credential;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user