反应本地Zendesk auth集成
我正在尝试将Zendesk与反应本来整合在一起。问题是我不知道Objective-C,因此我对身份验证有问题。 我想打开Zendeskchat,因为我可以以两种不同的方式(匿名或auth)做到这一点。要使用验证过程,我必须在打开聊天之前从服务器创建JWT并将其发送给Zendesk。我从Zendesk文档中复制一些功能,但是因为我的Knowladge湖具有Objective-C,所以我不知道如何将令牌传递给Zendesk。
我不知道如何使用此代码。
@implementation ZDKAuthJWT
- (void)getToken:(void (^)(NSString * _Nullable, NSError * _Nullable))completion {
// Call completion block once you get the JWT token
completion(<"token">, <"error">);
}
我应该在这里称呼它:
RCT_EXPORT_METHOD(setUserIdentity: (NSDictionary *)user) {
if (user[@"token"]) {
id<ZDKObjCIdentity> userIdentity = [[ZDKObjCJwt alloc] initWithToken:user[@"token"]];
[[ZDKZendesk instance] setIdentity:userIdentity];
RCTAuthJWT *authenticator = [RCTAuthJWT new];
[ZDKChat.instance setIdentityWithAuthenticator:authenticator];
} else {
id<ZDKObjCIdentity> userIdentity = [[ZDKObjCAnonymous alloc] initWithName:user[@"name"] // name is nullable
email:user[@"email"]]; // email is nullable
[[ZDKZendesk instance] setIdentity:userIdentity];
}
}
I am trying to integrate zendesk with react-native. The problem is that I don't know objective-c so I am having problem with the authentication.
I want to open ZenDeskChat, for that I can do it in 2 different way (anonymous or auth). To use the auth procedure I have to create a JWT from my server and send this token to zendesk before I open the chat. I copy some function from zendesk documentation but because my lake of knowladge with objective-c I can't figure out how to pass the token to zendesk.
I don't know how to use this code.
@implementation ZDKAuthJWT
- (void)getToken:(void (^)(NSString * _Nullable, NSError * _Nullable))completion {
// Call completion block once you get the JWT token
completion(<"token">, <"error">);
}
I am supposed to call it somewhere here :
RCT_EXPORT_METHOD(setUserIdentity: (NSDictionary *)user) {
if (user[@"token"]) {
id<ZDKObjCIdentity> userIdentity = [[ZDKObjCJwt alloc] initWithToken:user[@"token"]];
[[ZDKZendesk instance] setIdentity:userIdentity];
RCTAuthJWT *authenticator = [RCTAuthJWT new];
[ZDKChat.instance setIdentityWithAuthenticator:authenticator];
} else {
id<ZDKObjCIdentity> userIdentity = [[ZDKObjCAnonymous alloc] initWithName:user[@"name"] // name is nullable
email:user[@"email"]]; // email is nullable
[[ZDKZendesk instance] setIdentity:userIdentity];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论