From 101a761acfd84eef4049846b19092e78b3feb1d8 Mon Sep 17 00:00:00 2001 From: pavaniG Date: Thu, 4 Aug 2016 11:08:20 +0530 Subject: [PATCH 1/3] - AFNetworking upgraded to 3.0 --- HelpStack.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelpStack.podspec b/HelpStack.podspec index fb47446..4953c55 100644 --- a/HelpStack.podspec +++ b/HelpStack.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.platform = :ios, '7.0' s.source = { :git => "https://github.com/happyfoxinc/helpstack.git", :tag => "1.1.1", :submodules => true } s.resources = ['Resources/*.png','Resources/*.storyboard'] - s.dependency 'AFNetworking', '~> 2.0' + s.dependency 'AFNetworking', '~> 3.0’ s.frameworks = 'UIKit', 'CoreGraphics' s.requires_arc = true From 8b4a48d1a262b14eec70e11addb00aa2bf9ec438 Mon Sep 17 00:00:00 2001 From: pavaniG Date: Thu, 4 Aug 2016 11:14:42 +0530 Subject: [PATCH 2/3] AFNetworking upgraded to 3.0 --- HelpStack.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelpStack.podspec b/HelpStack.podspec index 4953c55..abb9af2 100644 --- a/HelpStack.podspec +++ b/HelpStack.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.platform = :ios, '7.0' s.source = { :git => "https://github.com/happyfoxinc/helpstack.git", :tag => "1.1.1", :submodules => true } s.resources = ['Resources/*.png','Resources/*.storyboard'] - s.dependency 'AFNetworking', '~> 3.0’ + s.dependency 'AFNetworking', '~> 3.0' s.frameworks = 'UIKit', 'CoreGraphics' s.requires_arc = true From 3e986794eb044044604e7e85f096b391c2a353d0 Mon Sep 17 00:00:00 2001 From: pavaniG Date: Wed, 17 Aug 2016 10:57:08 +0530 Subject: [PATCH 3/3] -Autorotation issue fixed - updated AFNetworking 3.0 framework --- Classes/Core/HSGear.h | 4 +- Classes/Stacks/Desk/HSDeskGear.m | 54 ++++----- Classes/Stacks/HappyFox/HSHappyFoxGear.m | 26 ++-- Classes/Stacks/ZenDesk/HSZenDeskGear.m | 50 +++++--- Classes/UI/HSIssueDetailViewController.h | 2 + Classes/UI/HSIssueDetailViewController.m | 10 +- Classes/UI/HSMainListViewController.h | 2 + Classes/UI/HSMainListViewController.m | 12 ++ Classes/UI/HSTicketDetailViewControlleriPad.m | 18 ++- Resources/HelpStackStoryboard-iPad.storyboard | 29 ++--- Resources/HelpStackStoryboard.storyboard | 112 +++++++++++------- 11 files changed, 194 insertions(+), 125 deletions(-) diff --git a/Classes/Core/HSGear.h b/Classes/Core/HSGear.h index 6cf0090..eb421bf 100644 --- a/Classes/Core/HSGear.h +++ b/Classes/Core/HSGear.h @@ -29,7 +29,7 @@ #import "HSNewTicket.h" #import "HSAttachment.h" #import "HSTicketReply.h" -#import +#import @@ -162,7 +162,7 @@ @property (nonatomic, strong) NSString* supportEmailAddress; @property (nonatomic, strong) NSString* localArticlePath; -@property (nonatomic, strong) AFHTTPRequestOperationManager* networkManager; +@property (nonatomic, strong) AFHTTPSessionManager* networkManager; @end diff --git a/Classes/Stacks/Desk/HSDeskGear.m b/Classes/Stacks/Desk/HSDeskGear.m index 88689aa..9c8cb2b 100644 --- a/Classes/Stacks/Desk/HSDeskGear.m +++ b/Classes/Stacks/Desk/HSDeskGear.m @@ -22,7 +22,7 @@ #import "HSDeskGear.h" #import "HSDeskKBItem.h" #import "HSDeskCase.h" -#import +#import #import "UIImage+Extended.h" #import @@ -44,14 +44,14 @@ - (instancetype)initWithInstanceBaseUrl:(NSString*)instanceBaseURL toHelpEmail:( NSURL* baseURL = [[NSURL alloc] initWithString:instanceBaseURL]; - AFHTTPRequestOperationManager* operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL]; + AFHTTPSessionManager* sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL]; - [operationManager setRequestSerializer:[AFJSONRequestSerializer serializer]]; - [operationManager.requestSerializer setAuthorizationHeaderFieldWithUsername:loginEmail password:password]; - [operationManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - [operationManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + [sessionManager setRequestSerializer:[AFJSONRequestSerializer serializer]]; + [sessionManager.requestSerializer setAuthorizationHeaderFieldWithUsername:loginEmail password:password]; + [sessionManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; + [sessionManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - self.networkManager = operationManager; + self.networkManager = sessionManager; [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; @@ -84,7 +84,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:( NSDictionary* params = @{ @"type":@"email", @"subject": newTicket.subject, @"_links":customerLinks, @"message":messageFields}; - [self.networkManager POST:@"api/v2/cases" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:@"api/v2/cases" parameters:params success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary* responsedata = (NSDictionary*)responseObject; @@ -104,9 +104,9 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:( NSString* attachmentPostURL = [caseLink stringByAppendingPathComponent:@"attachments"]; NSDictionary* attachmentParams = @{ @"file_name": attachment.fileName, @"content_type":@"image/png", @"content": attachment.attachmentImage.base64EncodedString }; - [self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(NSURLSessionTask *operation, id responseObject) { success(deskCase, user); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Case created. But Error creating attachment %@", error.localizedDescription); success(deskCase, user); }]; @@ -116,7 +116,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:( } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error creating case %@", error.localizedDescription); failure(error); @@ -141,7 +141,7 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes NSString* messageURL = [NSString stringWithFormat:@"%@/message", deskCase.apiHref]; - [self.networkManager GET:messageURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:messageURL parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { HSUpdate* originalMessage = [[HSUpdate alloc] init]; originalMessage.content = [responseObject objectForKey:@"body"]; @@ -158,7 +158,7 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes NSDictionary* params = @{@"sort_field": @"updated_at", @"sort_direction": @"asc"}; - [self.networkManager GET:repliesURL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:repliesURL parameters:params success:^(NSURLSessionTask *operation, id responseObject) { //got the replies @@ -189,13 +189,13 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes success(allReplies); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; @@ -224,7 +224,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU NSDictionary* messageFields = @{@"direction": @"in", @"body":reply.content, @"to": self.toHelpEmail}; //creating a user reply. - [self.networkManager POST:[NSString stringWithFormat:@"%@/replies", deskCase.apiHref] parameters:messageFields success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:[NSString stringWithFormat:@"%@/replies", deskCase.apiHref] parameters:messageFields success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary* responsedata = (NSDictionary*)responseObject; @@ -245,12 +245,12 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU NSString* attachmentPostURL = [deskCase.apiHref stringByAppendingPathComponent:@"attachments"]; NSDictionary* attachmentParams = @{ @"file_name": @"Screenshot", @"content_type":@"image/png", @"content": attachment.attachmentImage.base64EncodedString }; - [self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(NSURLSessionTask *operation, id responseObject) { userReply.attachments = reply.attachments; success(userReply); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Case created. But Error creating attachment %@", error.localizedDescription); success(userReply); }]; @@ -265,7 +265,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU success(userReply); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error replying to case %@", error.localizedDescription); failure(error); @@ -292,7 +292,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k if (!section) { // GET ALL SUPPORT CENTER TOPICS - [self.networkManager GET:@"/api/v2/topics" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:@"/api/v2/topics" parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary* response = (NSDictionary*)responseObject; NSNumber* numOfTopics = [response objectForKey:@"total_entries"]; @@ -322,7 +322,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k }else{ success(nil); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; @@ -334,7 +334,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k NSDictionary* articlesLinks = [deskTopic.apiLinks objectForKey:@"articles"]; - [self.networkManager GET:[articlesLinks objectForKey:@"href"] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:[articlesLinks objectForKey:@"href"] parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary* response = (NSDictionary*)responseObject; NSNumber* numEntries = [response objectForKey:@"total_entries"]; @@ -369,7 +369,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k }else{ success(nil); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; } @@ -386,7 +386,7 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid NSDictionary* params = @{@"email": user.email}; - [self.networkManager GET:@"api/v2/customers/search" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:@"api/v2/customers/search" parameters:params success:^(NSURLSessionTask *operation, id responseObject) { NSNumber* totalEntries = [responseObject objectForKey:@"total_entries"]; @@ -448,7 +448,7 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid NSArray* emails = @[@{@"type": @"home", @"value":user.email}]; NSDictionary* params = @{@"first_name": user.firstName, @"last_name":user.lastName, @"emails":emails }; - [self.networkManager POST:@"api/v2/customers" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:@"api/v2/customers" parameters:params success:^(NSURLSessionTask *operation, id responseObject) { HSUser* validUser = nil; validUser = [[HSUser alloc] init]; @@ -465,14 +465,14 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid success(validUser); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error while creating customer record."); failure(error); }]; } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error while searching customer record."); failure(error); diff --git a/Classes/Stacks/HappyFox/HSHappyFoxGear.m b/Classes/Stacks/HappyFox/HSHappyFoxGear.m index 4eb5ec1..0d6a8ff 100644 --- a/Classes/Stacks/HappyFox/HSHappyFoxGear.m +++ b/Classes/Stacks/HappyFox/HSHappyFoxGear.m @@ -45,7 +45,7 @@ - (id)initWithInstanceUrl:(NSString*) instanceUrl apiKey:(NSString *)api_key aut self.instanceUrl = instanceUrl; self.hfCategoryID = category_ID; self.hfPriorityID = priority_ID; - self.networkManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]]; + self.networkManager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]]; [self.networkManager setRequestSerializer:[AFJSONRequestSerializer serializer]]; [self.networkManager setResponseSerializer:[AFJSONResponseSerializer serializer]]; [self.networkManager.requestSerializer setAuthorizationHeaderFieldWithUsername:self.api_key password:self.auth_code]; @@ -64,7 +64,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k url = [url stringByAppendingString:self.hfSectionID]; url = [url stringByAppendingString:@"/"]; } - [self.networkManager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:url parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { self.articleSections = responseObject; if(self.hfSectionID){ NSMutableArray *articles = [self getArticlesFromSection:responseObject]; @@ -73,7 +73,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k NSMutableArray *sections = [self getSectionsFromData:responseObject]; success(sections); } - }failure:^(AFHTTPRequestOperation *operation, NSError *error) { + }failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; } else { @@ -111,10 +111,10 @@ -(NSMutableArray *)getSectionsFromData:(NSDictionary *)responseData{ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user success:(void (^)(NSMutableArray* updateArray))success failure:(void (^)(NSError* e))failure { NSString *getString = @"api/1.1/json/ticket/"; getString = [getString stringByAppendingString:ticket.ticketID]; - [self.networkManager GET:getString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:getString parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { NSMutableArray *tickUpdates = [self getTicketUpdatesFromResponseData:responseObject]; success(tickUpdates); - }failure:^(AFHTTPRequestOperation *operation, NSError *error) { + }failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; } @@ -179,7 +179,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:( [formData appendPartWithFileData:attachment.attachmentData name:@"attachments" fileName:((HSAttachment *)attachment).fileName mimeType:((HSAttachment *)attachment).mimeType]; } } - }success:^(AFHTTPRequestOperation *operation, id responseObject) { + }success:^(NSURLSessionTask *operation, id responseObject) { HSTicket *issue = [[HSTicket alloc] init]; issue.subject = [responseObject objectForKey:@"subject"]; issue.ticketID = [[responseObject objectForKey:@"id"] stringValue]; @@ -188,11 +188,11 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:( NSString* userId = [[[responseObject objectForKey:@"user"] objectForKey:@"id"] stringValue]; hfUser.apiHref = userId; success(issue, hfUser); - }failure:^(AFHTTPRequestOperation *operation, NSError *error) { + }failure:^(NSURLSessionTask *operation, NSError *error) { HALog(@"Failed to create a ticket %@", error); - if (operation.responseString) { - HALog(@"Error Description %@", operation.responseString); + if (operation.taskDescription) { + HALog(@"Error Description %@", operation.taskDescription); } failure(error); }]; @@ -213,7 +213,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU for(HSAttachment *attachment in attachments){ [formData appendPartWithFileData:attachment.attachmentData name:@"attachments" fileName:attachment.fileName mimeType:attachment.mimeType]; } - } success:^(AFHTTPRequestOperation *operation, id responseObject) { + } success:^(NSURLSessionTask *operation, id responseObject) { HSUpdate *recentUpdate = [[HSUpdate alloc] init]; recentUpdate.from = user.name; @@ -223,10 +223,10 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU recentUpdate.updateType = HATypeUserReply; success(recentUpdate); //Send all the updates - }failure:^(AFHTTPRequestOperation *operation, NSError *error) { + }failure:^(NSURLSessionTask *operation, NSError *error) { HALog(@"Failed to update Ticket %@", error); - if (operation.responseString) { - HALog(@"Error Description %@", operation.responseString); + if (operation.taskDescription) { + HALog(@"Error Description %@", operation.taskDescription); } failure(error); }]; diff --git a/Classes/Stacks/ZenDesk/HSZenDeskGear.m b/Classes/Stacks/ZenDesk/HSZenDeskGear.m index d647fb8..8acee5f 100644 --- a/Classes/Stacks/ZenDesk/HSZenDeskGear.m +++ b/Classes/Stacks/ZenDesk/HSZenDeskGear.m @@ -20,7 +20,7 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. -#import +#import #import #import "HSZenDeskGear.h" @@ -53,7 +53,7 @@ - (id)initWithInstanceUrl:(NSString*)instanceUrl staffEmailAddress:(NSString *)s self.staffEmailAddress = staffEmailAddress; self.apiToken = apiToken; - self.networkManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]]; + self.networkManager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]]; [self.networkManager setRequestSerializer:[AFJSONRequestSerializer serializer]]; [self.networkManager setResponseSerializer:[AFJSONResponseSerializer serializer]]; @@ -65,7 +65,7 @@ - (id)initWithInstanceUrl:(NSString*)instanceUrl staffEmailAddress:(NSString *)s - (void)showArticlesInSection:(NSString *)sectionID failure:(void (^)(NSError *))failure success:(void (^)(NSMutableArray *))success { - [self.networkManager GET:[NSString stringWithFormat:@"/api/v2/help_center/sections/%@/articles.json", sectionID] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:[NSString stringWithFormat:@"/api/v2/help_center/sections/%@/articles.json", sectionID] parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary *response = (NSDictionary *)responseObject; NSNumber *numEntries = [response objectForKey:@"count"]; @@ -88,7 +88,7 @@ - (void)showArticlesInSection:(NSString *)sectionID failure:(void (^)(NSError *) success(nil); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; } @@ -101,7 +101,7 @@ - (void)fetchKBForSection:(HSKBItem *)section success:(void (^)(NSMutableArray * if(!self.sectionID) { NSString *url = @"/api/v2/help_center/sections.json"; - [self.networkManager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:url parameters:nil success:^(NSURLSessionTask *operation, id responseObject) { NSDictionary *response = (NSDictionary *)responseObject; NSNumber *numOfTopics = [response objectForKey:@"count"]; @@ -124,7 +124,7 @@ - (void)fetchKBForSection:(HSKBItem *)section success:(void (^)(NSMutableArray * success(nil); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); }]; } else { @@ -203,11 +203,11 @@ - (void) createNewZendeskTicket:(HSNewTicket *)newTicket forUser:(HSUser *)user }; - [self.networkManager POST:url parameters:ticketDictionary success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager POST:url parameters:ticketDictionary success:^(NSURLSessionTask *operation, id responseObject) { // Save ticket details so next time it is ready for user to use. HSZenDeskTicket* ticket = [[HSZenDeskTicket alloc] initWithTicketFields:responseObject]; operationSuccess(ticket); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { operationFailure(error); }]; } failure:^(NSError* error) { @@ -229,7 +229,7 @@ - (void) uploadAttachments:(NSArray *)attachments success:(void (^)(NSArray *att NSString* URLString = [[NSURL URLWithString:[NSString stringWithFormat:@"api/v2/uploads.json?filename=%@", attachment.fileName] relativeToURL:[NSURL URLWithString:self.instanceUrl]] absoluteString]; - AFHTTPRequestOperationManager* attachmentnetworkManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:self.instanceUrl]]; + AFHTTPSessionManager* attachmentnetworkManager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:self.instanceUrl]]; [attachmentnetworkManager.requestSerializer setAuthorizationHeaderFieldWithUsername:[self.staffEmailAddress stringByAppendingString:@"/token"] password:self.apiToken]; @@ -246,15 +246,29 @@ - (void) uploadAttachments:(NSArray *)attachments success:(void (^)(NSArray *att [attachmentnetworkManager.responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"text/plain"]]; - // Use [self.networkManager HTTPRequestOperationWithRequest - AFHTTPRequestOperation *operation = [attachmentnetworkManager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { + + [attachmentnetworkManager POST:URLString parameters:nil constructingBodyWithBlock:^(id _Nonnull formData) { + [formData appendPartWithFileData:attachment.attachmentData + name:@"files" + fileName:attachment.fileName mimeType:@"image/jpeg"]; + } progress:^(NSProgress * _Nonnull uploadProgress) { + } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSDictionary* uploadDict = [responseObject objectForKey:@"upload"]; success(@[[uploadDict objectForKey:@"token"]]); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - operationFailure(error); + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + NSLog(@"Error: %@", error); }]; - [operation start]; + +// // Use [self.networkManager HTTPRequestOperationWithRequest +// AFHTTPSessionManager *operation = [attachmentnetworkManager HTTPRequestOperationWithRequest:request success:^(NSURLSessionTask *operation, id responseObject) { +// NSDictionary* uploadDict = [responseObject objectForKey:@"upload"]; +// success(@[[uploadDict objectForKey:@"token"]]); +// } failure:^(NSURLSessionTask *operation, NSError *error) { +// operationFailure(error); +// }]; +// +// [operation start]; } @@ -264,7 +278,7 @@ - (void)reloadTicket:(NSString*)ticketId success:(void (^) (NSMutableArray* tick NSDictionary* parameter = @{@"include":@"users"}; [self.networkManager.requestSerializer setAuthorizationHeaderFieldWithUsername:[self.staffEmailAddress stringByAppendingString:@"/token"] password:self.apiToken]; - [self.networkManager GET:url parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager GET:url parameters:parameter success:^(NSURLSessionTask *operation, id responseObject) { // Read all data NSArray* auditsDictionary = [responseObject objectForKey:@"audits"]; NSArray* usersDictionary = [responseObject objectForKey:@"users"]; @@ -285,7 +299,7 @@ - (void)reloadTicket:(NSString*)ticketId success:(void (^) (NSMutableArray* tick success(filteredArray); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); @@ -303,12 +317,12 @@ - (void)addReply:(NSString *)message ticketId:(NSString *)ticketId attachments:( NSString* url = [NSString stringWithFormat:@"api/v2/requests/%@.json", ticketId]; NSDictionary* parameter = @{@"request":@{ @"comment":@{ @"body":message, @"uploads":attachmentTokens } }}; [self.networkManager.requestSerializer setAuthorizationHeaderFieldWithUsername:[user.email stringByAppendingString:@"/token"] password:self.apiToken]; - [self.networkManager PUT:url parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.networkManager PUT:url parameters:parameter success:^(NSURLSessionTask *operation, id responseObject) { HSZenDeskTicketUpdate* update = [[HSZenDeskTicketUpdate alloc] initUserReplyWithAuthorName:user.name message:message attachments:attachments]; success(update); - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(NSURLSessionTask *operation, NSError *error) { failure(error); diff --git a/Classes/UI/HSIssueDetailViewController.h b/Classes/UI/HSIssueDetailViewController.h index 64b01f1..0374a5d 100644 --- a/Classes/UI/HSIssueDetailViewController.h +++ b/Classes/UI/HSIssueDetailViewController.h @@ -43,6 +43,8 @@ @property (weak, nonatomic) IBOutlet UIButton *addAttachmentButton; @property (nonatomic, assign) float bubbleWidth; @property (strong, nonatomic) IBOutlet HSGrowingTextView *messageText; +@property (unsafe_unretained, nonatomic) IBOutlet NSLayoutConstraint *messageViewHeightConstraint; +@property (unsafe_unretained, nonatomic) IBOutlet NSLayoutConstraint *textViewHeightConstraint; @property (weak, nonatomic) IBOutlet UIView *messageTextSuperView; @property (unsafe_unretained, nonatomic) IBOutlet UIActivityIndicatorView *loadingIndicator; diff --git a/Classes/UI/HSIssueDetailViewController.m b/Classes/UI/HSIssueDetailViewController.m index a9f4e9c..ed6d97d 100644 --- a/Classes/UI/HSIssueDetailViewController.m +++ b/Classes/UI/HSIssueDetailViewController.m @@ -135,7 +135,7 @@ - (void)addMessageView { } self.messageText.returnKeyType = UIReturnKeyGo; - self.messageText.font = [UIFont systemFontOfSize:14.0f]; + self.messageText.font = [UIFont systemFontOfSize:17.0f]; self.messageText.delegate = self; self.messageText.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(5, 0, 5, 0); @@ -168,7 +168,7 @@ - (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(f msgViewFrame.size.height -= diff; msgViewFrame.origin.y += diff; - self.messageText.frame = growingTextView.frame; + // self.messageText.frame = growingTextView.frame; UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, self.chatTableView.contentInset.bottom - diff , 0.0); self.chatTableView.contentInset = contentInsets; @@ -177,7 +177,8 @@ - (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(f [self scrollDownToLastMessage:YES]; self.bottomMessageView.frame = msgViewFrame; - + self.textViewHeightConstraint.constant = msgViewFrame.size.height; + } -(void)growingTextViewDidChange:(HSGrowingTextView *)growingTextView{ @@ -496,6 +497,9 @@ - (void)keyboardFrameWillChange: (NSNotification *)notification { // set views with new info self.bottomMessageView.frame = containerFrame; + self.messageViewHeightConstraint.constant = ([[[UIApplication sharedApplication] delegate] window].frame.size.height - kKeyBoardFrame.origin.y); + NSLog(@"window %f",self.messageViewHeightConstraint.constant); + [UIView commitAnimations]; [self scrollDownToLastMessage:YES]; } diff --git a/Classes/UI/HSMainListViewController.h b/Classes/UI/HSMainListViewController.h index 9b64de1..12b92e8 100644 --- a/Classes/UI/HSMainListViewController.h +++ b/Classes/UI/HSMainListViewController.h @@ -29,7 +29,9 @@ #import "HSTableViewController.h" @interface HSMainListViewController : HSTableViewController +@property (strong, nonatomic) UISearchController *searchController; - (IBAction)cancelPressed:(UIBarButtonItem *)sender; + @end diff --git a/Classes/UI/HSMainListViewController.m b/Classes/UI/HSMainListViewController.m index 8903a19..2bcf160 100644 --- a/Classes/UI/HSMainListViewController.m +++ b/Classes/UI/HSMainListViewController.m @@ -80,6 +80,18 @@ - (void)viewDidLoad [self refreshMyIssue]; [self addCreditsToTable]; + + self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; + self.searchController.searchResultsUpdater = self; + self.searchController.searchBar.delegate = self; + + [self.searchController.searchBar sizeToFit]; + + // Add the UISearchBar to the top header of the table view + self.tableView.tableHeaderView = self.searchController.searchBar; + + // Hides search bar initially. When the user pulls down on the list, the search bar is revealed. + [self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height)]; } - (void)viewDidAppear:(BOOL)animated diff --git a/Classes/UI/HSTicketDetailViewControlleriPad.m b/Classes/UI/HSTicketDetailViewControlleriPad.m index 3773cdb..7909977 100644 --- a/Classes/UI/HSTicketDetailViewControlleriPad.m +++ b/Classes/UI/HSTicketDetailViewControlleriPad.m @@ -70,6 +70,16 @@ - (void)addMessageView{ self.messageText.layer.cornerRadius = 5.0; [self.bottomMessageView addSubview:self.messageText]; + if([[self ticketSource] draftReplyMessage]!=nil) { + self.messageText.text = [[self ticketSource] draftReplyMessage]; + } + else { + self.messageText.text = @""; + self.messageText.placeholder = @"Reply here"; + } + + + } - (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(float)height @@ -91,7 +101,8 @@ - (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(f self.chatTableView.scrollIndicatorInsets = contentInsets; [self scrollDownToLastMessage:YES]; - + self.textViewHeightConstraint.constant = msgViewFrame.size.height; + self.bottomMessageView.frame = msgViewFrame; } @@ -145,7 +156,7 @@ - (void)keyboardFrameWillChange: (NSNotification *)notification { if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) { - containerFrame.origin.y = kKeyBoardFrame.origin.y - containerFrame.size.height - 256; + containerFrame.origin.y = kKeyBoardFrame.origin.y - containerFrame.size.height - 256 + 33; } else { // On ios 7 landscape x == ios 8 landscape y @@ -188,7 +199,10 @@ - (void)keyboardFrameWillChange: (NSNotification *)notification { // set views with new info self.bottomMessageView.frame = containerFrame; + // self.messageViewHeightConstraint.constant = ([[[UIApplication sharedApplication] delegate] window].frame.size.height - kKeyBoardFrame.origin.y); + NSLog(@"window %f",self.messageViewHeightConstraint.constant); + [UIView commitAnimations]; } diff --git a/Resources/HelpStackStoryboard-iPad.storyboard b/Resources/HelpStackStoryboard-iPad.storyboard index a4d9ede..423fa30 100644 --- a/Resources/HelpStackStoryboard-iPad.storyboard +++ b/Resources/HelpStackStoryboard-iPad.storyboard @@ -1,7 +1,7 @@ - + - + @@ -71,7 +71,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -145,10 +145,10 @@ - + - + @@ -179,10 +179,10 @@ - + - + @@ -607,7 +607,6 @@ - @@ -618,8 +617,10 @@ + + @@ -715,7 +716,7 @@