您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页阿里百川用户反馈界面集成

阿里百川用户反馈界面集成

来源:二三四教育网

集成步骤请参考百川文档

通过按钮触发 actionOpenFeedback 方法就可以进入反馈聊天界面

--- 调起意见反馈

- (void )actionOpenFeedback{
//    self.tabBarController.tabBar.hidden = YES;

self.appKey = @"你的KEY";
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 这里可以设置你需要显示的标题以及nav的leftBarButtonItem,rightBarButtonItem
        viewController.title = @"意见反馈";
        

        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn-back-h"] style:UIBarButtonItemStylePlain target:weakSelf action:@selector(cancelButtonAction)];
        viewController.navigationItem.leftBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-20,0,0);
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
        

        [self.navigationController pushViewController:viewController animated:YES];
        
        viewController.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
        self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;
        
        viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithHexString:@"#ffffff"];
        viewController.tabBarController.tabBar.hidden = YES;
        
        __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];
    }
}];
}

弹出的反馈界面导航条和app导航条UI不同,需要自己设置

 viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn-back-h"] style:UIBarButtonItemStylePlain target:weakSelf action:@selector(cancelButtonAction)];
viewController.navigationItem.leftBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-20,0,0);
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];

参考文章:

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务