正常的添加阿里百川的依赖库,具体参考官方文档。地址如下:
https://baichuan.taobao.com/doc2/detail.htm?spm=a3c0d.7629140.0.0.cCQwwt&treeId=118&articleId=104173&docType=1
其他的就是参考官方demo写的,注意一点的是要写明环境。
key是跟阿里申请的
//反馈(阿里百川)
self.appKey = @"******";
//匿名反馈
self.feedbackKit = [[YWFeedbackKit alloc] initWithAppKey:self.appKey];
// 开发者的线上环境
_feedbackKit.environment = YWEnvironmentRelease;
#warning 设置App自定义扩展反馈数据
// _feedbackKit.extInfo = @{@"loginTime":[[NSDate date] description],
// @"visitPath":@"登陆->关于->反馈",
// @"应用自定义扩展信息":@"开发者可以根据需要设置不同的自定义信息,方便在反馈系统中查看"};
#warning 自定义反馈页面配置
// _feedbackKit.customUIPlist = [NSDictionary dictionaryWithObjectsAndKeys:@"/te\'st\\Value1\"", @"testKey1", @"test<script>alert(\"error.yaochen\")</alert>Value2", @"testKey2", nil];
[self _openFeedbackViewController];
- (void)_openFeedbackViewController
{
__weak typeof(self) weakSelf = self;
//登录并创建反馈页面
[_feedbackKit makeFeedbackViewControllerWithCompletionBlock:^(YWFeedbackViewController *viewController, NSError *error) {
if ( viewController != nil ) {
//#warning 这里可以设置你需要显示的标题
viewController.title = @"反馈界面";
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
[weakSelf presentViewController:nav animated:YES completion:nil];
viewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:weakSelf action:@selector(actionQuitFeedback)];
// viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"清除缓存" style:UIBarButtonItemStylePlain
// target:weakSelf action:@selector(actionCleanMemory:)];
__weak typeof(nav) weakNav = nav;
[viewController setOpenURLBlock:^(NSString *aURLString, UIViewController *aParentController) {
UIViewController *webVC = [[UIViewController alloc] initWithNibName:nil bundle:nil];
UIWebView *webView = [[UIWebView alloc] initWithFrame:webVC.view.bounds];
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
[webVC.view addSubview:webView];
[weakNav pushViewController:webVC animated:YES];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aURLString]]];
}];
} else {
// NSString *title = [error.userInfo objectForKey:@"msg"]?:@"接口调用失败,请保持网络通畅!";
// [[TWMessageBarManager sharedInstance] showMessageWithTitle:title description:nil
// type:TWMessageBarMessageTypeError];
}
}];
}
效果图: