我正在尝试桥接Zendesk支持SDK,以便在我的本机应用程序中进行渲染。
以下是我通常在objective-c中所做的事情:
#import "ViewController.h"
#import <ZendeskSDK/ZendeskSDK.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)ButtonPress:(id)sender {
[ZDKHelpCenter presentHelpCenterWithViewController:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
如何使用RCT_EXPORT_METHOD来桥接?
目前我有这样的事情:
#import "zendeskSupportView.h"
#import <ZendeskSDK/ZendeskSDK.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
@implementation zendeskSupportView
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(findEvents:(RCTResponseSenderBlock)callback)
{
UIViewController *rootController = [UIApplication sharedApplication].delegate.window.rootViewController;
rootController = [rootController topMostController];
[ZDKHelpCenter presentHelpCenterWithViewController:rootController];
}
@end
答案 0 :(得分:1)
要设置本机模块,您可以参考本地module documentation做出反应,或者查看我之前在项目中创建的gist of a small module我打开IOS设置应用程序。
在您的RCT_EXPORT_METHOD宏代码中,您需要调用[ZDKHelpCenter presentHelpCenterWithViewController:self];
。由于此函数中没有直接可用的控制器实例,您可以执行以下操作:
UIViewController *rootController = [UIApplication sharedApplication].delegate.window.rootViewController;
rootController = [rootController topMostController];
[ZDKHelpCenter presentHelpCenterWithViewController:rootController];
上面的代码,将ios控制器堆栈中最顶层的控制器传递给ZendDeskHelpCenter。