Skip to content

Commit

Permalink
release 4.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xushichen committed Jul 29, 2020
1 parent 8bcc9d2 commit c6e70f8
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 415 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ https://github.com/udesk/UdeskSDK-iOS

| 类别 | 兼容范围 |
| -------- | ----------------------------- |
| 系统 | 支持iOS 7.0及以上系统 |
| 系统 | 支持iOS 8.0及以上系统 |
| 架构 | armv7、arm64、i386、x86_64 |
| 开发环境 | 建议使用最新版本Xcode进行开发 |

Expand Down Expand Up @@ -962,6 +962,12 @@ chatViewManager.orientationMask = UIInterfaceOrientationMaskPortrait;
#### 更新记录:
sdk v4.3.2版本更新功能:
1.替换UIWebView
------
sdk v4.3.1版本更新功能:
1.修改上传文件策略
Expand Down
4 changes: 2 additions & 2 deletions UdeskSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

Pod::Spec.new do |s|
s.name = 'UdeskSDK'
s.version = '4.3.1'
s.version = '4.3.2'
s.license = 'MIT'
s.summary = 'Udesk SDK for iOS'
s.homepage = 'https://github.com/udesk/UdeskSDK-iOS'
s.author = {'xuchen ' => 'xuc@udesk.cn'}
s.source = {:git => 'https://github.com/udesk/UdeskSDK-iOS.git', :tag => s.version.to_s }
s.platform = :ios, '6.0'
s.platform = :ios, '8.0'
s.requires_arc = true

s.subspec 'SDK' do |ss|
Expand Down
2 changes: 1 addition & 1 deletion UdeskSDK/SDK/UdeskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// UdeskManager.h
// UdeskSDK
//
// Version: 4.3.1
// Version: 4.3.2
//
// Created by Udesk on 16/1/12.
// Copyright © 2016年 Udesk. All rights reserved.
Expand Down
Binary file modified UdeskSDK/SDK/libUdesk.a
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <UIKit/UIKit.h>

@interface UdeskContentController : UIViewController<UIWebViewDelegate>
@interface UdeskContentController : UIViewController

/**
* 文章ID
Expand Down
44 changes: 21 additions & 23 deletions UdeskSDK/UDChatMessage/UDFAQ/Controller/UdeskContentController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#import "UdeskManager.h"
#import "UdeskSDKConfig.h"
#import "UdeskTransitioningAnimation.h"
#import <WebKit/WebKit.h>

@interface UdeskContentController (){
@interface UdeskContentController ()<WKUIDelegate,WKNavigationDelegate>{

UILabel *_labelTitle;
BOOL isLoadingFinished;
UIWebView *htmlWebView;
WKWebView *htmlWebView;
NSString *_htmlContent;

}

@end
Expand Down Expand Up @@ -113,7 +113,6 @@ - (void)dismissChatViewController {
} else {
[self dismissViewControllerAnimated:YES completion:nil];
}

}

//加载数据
Expand All @@ -136,17 +135,25 @@ - (void)initLoad {
_labelTitle.hidden = NO;
}
}];

}

- (void)loadHtmlContent:(NSString *)htmlString baseUrl:(NSString *)baseUrl {

@try {

// 自适应屏幕宽度js
NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController *wkUController = [[WKUserContentController alloc] init];
[wkUController addUserScript:wkUScript];
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;

CGFloat webY = _labelTitle.frame.origin.y+_labelTitle.frame.size.height+5;
htmlWebView=[[UIWebView alloc] initWithFrame:CGRectMake(7, webY, UD_SCREEN_WIDTH-14, self.view.frame.size.height-webY)];
htmlWebView=[[WKWebView alloc] initWithFrame:CGRectMake(7, webY, UD_SCREEN_WIDTH-14, self.view.frame.size.height-webY) configuration:wkWebConfig];
htmlWebView.backgroundColor = [UIColor whiteColor];
htmlWebView.delegate = self;
htmlWebView.UIDelegate = self;
htmlWebView.navigationDelegate = self;
NSString *newBaseURL = [NSString stringWithFormat:@"http://%@",baseUrl];

[htmlWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:newBaseURL]];
Expand All @@ -158,9 +165,9 @@ - (void)loadHtmlContent:(NSString *)htmlString baseUrl:(NSString *)baseUrl {
}
}

#pragma mark - UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
#pragma mark - WKWebViewDelegate
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
@try {

for (UIView *_aView in [htmlWebView subviews])
Expand All @@ -187,22 +194,13 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
}
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {

if (navigationType == UIWebViewNavigationTypeLinkClicked) {

[[UIApplication sharedApplication] openURL:request.URL];

return NO;
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
}

return YES;
}

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

decisionHandler(WKNavigationActionPolicyAllow);
}

@end
95 changes: 54 additions & 41 deletions UdeskSDK/UDChatMessage/UDFAQ/Controller/UdeskFAQViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@
//

#import "UdeskFAQViewController.h"
#import "UdeskSDKMacro.h"
#import "UdeskBundleUtils.h"
#import "UdeskProblemModel.h"
#import "UdeskContentController.h"
#import "UdeskManager.h"
#import "UdeskSDKConfig.h"
#import "UdeskSearchController.h"
#import "UdeskTransitioningAnimation.h"
#import "UIImage+UdeskSDK.h"
#import "UdeskSDKShow.h"
#import "UdeskThrottleUtil.h"

@interface UdeskFAQViewController ()<UISearchBarDelegate,UISearchDisplayDelegate>
@interface UdeskFAQViewController ()<UISearchResultsUpdating,UISearchControllerDelegate>

/** 帮助中心表示图 */
@property (nonatomic, strong) UITableView *faqTableView;
/** 帮助中心数据数组 */
@property (nonatomic, strong) NSArray *problemData;
/** 搜索vc */
@property (nonatomic, strong) UdeskSearchController *searchController;
/** 搜索 */
@property (nonatomic, strong) UISearchController *searchController;

@property (nonatomic, strong) UdeskSDKConfig *sdkConfig;

@end
Expand Down Expand Up @@ -95,7 +92,6 @@ - (void)dismissChatViewController {
} else {
[self dismissViewControllerAnimated:YES completion:nil];
}

}

#pragma mark - 添加帮助中心TableView和搜索
Expand All @@ -105,30 +101,15 @@ - (void)faqTableViewAndSearch {
_faqTableView.backgroundColor = [UIColor colorWithRed:0.918f green:0.922f blue:0.925f alpha:1];
_faqTableView.dataSource = self;
_faqTableView.delegate = self;
_faqTableView.tableFooterView = [UIView new];
[self.view addSubview:_faqTableView];


//删除多余的cell
UIView *footerView = [[UIView alloc] initWithFrame:CGRectZero];
[_faqTableView setTableFooterView:footerView];

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.f, 0.f,UD_SCREEN_WIDTH, 44)];
searchBar.tintColor = [UIColor colorWithRed:33/255.0f green:40/255.0f blue:42/255.0f alpha:1];

_faqTableView.tableHeaderView = searchBar;

UdeskSearchController *searchDisplayController = [[UdeskSearchController alloc] initWithSearchBar:searchBar
contentsController:self];


self.searchController = searchDisplayController;

_faqTableView.tableHeaderView = self.searchController.searchBar;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return _problemData.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Expand All @@ -154,6 +135,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

@try {

if (self.searchController.active) {
self.searchController.active = NO;
[self.searchController.searchBar removeFromSuperview];
}

UdeskContentController *content = [[UdeskContentController alloc] init];
UdeskProblemModel *model = _problemData[indexPath.row];
content.articleId = model.articleId;
Expand All @@ -167,17 +153,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

#pragma mark UISearchBarDelegate

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
return YES;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
}
#pragma mark - 请求数据
- (void)requestFAQData {

Expand All @@ -191,7 +166,7 @@ - (void)requestFAQData {
NSMutableArray *muArray = [NSMutableArray array];
NSArray *contents = [responseObject objectForKey:@"contents"];
for (NSDictionary *dic in contents) {
UdeskProblemModel *model = [[UdeskProblemModel alloc] initWithContentsOfDic:dic];
UdeskProblemModel *model = [[UdeskProblemModel alloc] initModelWithJSON:dic];
if (model) {
[muArray addObject:model];
}
Expand All @@ -209,13 +184,51 @@ - (void)requestFAQData {
} @finally {
}
}];

}

-(void)dealloc {
- (UISearchController *)searchController {

_faqTableView = nil;
if (!_searchController) {

_searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
_searchController.searchResultsUpdater = self;
_searchController.delegate = self;
_searchController.dimsBackgroundDuringPresentation = NO;
_searchController.searchBar.frame = CGRectMake(_searchController.searchBar.frame.origin.x, _searchController.searchBar.frame.origin.y, _searchController.searchBar.frame.size.width, 44.0);
_searchController.searchBar.backgroundColor = [UIColor colorWithRed:0.953f green:0.953f blue:0.953f alpha:1];
_searchController.searchBar.barTintColor = [UIColor colorWithRed:0.953f green:0.953f blue:0.953f alpha:1];
_searchController.searchBar.backgroundImage = [UIImage new];
_searchController.searchBar.placeholder = @"搜索";
}
return _searchController;
}

#pragma mark - @protocol UISearchResultsUpdating
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {

//设置时间阈值来限制方法调用频率
ud_dispatch_throttle(0.35f, ^{
if (searchController.searchBar.text.length == 0) {
[self requestFAQData];
return ;
}

[UdeskManager searchFaqArticles:searchController.searchBar.text completion:^(id responseObject, NSError *error) {

if (!error) {

NSMutableArray *array = [NSMutableArray array];
NSArray *contents = [responseObject objectForKey:@"contents"];
for (NSDictionary *dic in contents) {
UdeskProblemModel *model = [[UdeskProblemModel alloc] initModelWithJSON:dic];
[array addObject:model];
}

self.problemData = [array copy];
[self.faqTableView reloadData];
}
}];
});
}

- (void)didReceiveMemoryWarning {
Expand Down
26 changes: 0 additions & 26 deletions UdeskSDK/UDChatMessage/UDFAQ/Controller/UdeskSearchController.h

This file was deleted.

Loading

0 comments on commit c6e70f8

Please sign in to comment.