反应本地Zendesk auth集成

发布于 2025-02-04 18:16:51 字数 1166 浏览 2 评论 0原文

我正在尝试将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文