收藏
回答

企业微信jssdk api在pc端可以调的通,手机端安卓可以,但是ios不行,这是什么情况?急!

问题描述:

企业微信自建H5应用,用的PCweb项目进行页面适配的。企业微信PC端自建应用功能已经上线了,正常运行。准备在移动端也上线,代码没有进行改动,测试发现,安卓手机 应用功能正常。主要在iphone上,发现agentConfig 返回正常,但是invoke getCurExternalContact getCurExternalChat Api 返回error,功能无法正常往下运行。

具体返回的info在下面注释里,各位大佬麻烦帮看下问题!!!

sdk地址:

<script src=https://res.wx.qq.com/wwopen/js/jsapi/jweixin-1.0.0.js></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

代码片段:

wx.agentConfig({
  corpid: appId,
  agentid: agentId,
  timestamp,
  nonceStr,
  signature,
  jsApiList: [
    "getCurExternalContact",
    "getCurExternalChat",
    "sendChatMessage",
  ],
  success: function (res) {
    _this.logMessage += `wx agentConfig:${JSON.stringify(res)}`
//
//{"err_Info":"success","checkResult":{"sendChatMessage":true,"getCurExternalContact":true,"getCurExternalChat":true},"errMsg":"agentConfig:ok"}
//
      wx.invoke("getCurExternalContact", {}, function (res) {
        console.log("invoke-getCurExternalContact", res);
//
//{"err_code":2,"err_msg":"getCurExternalContact:fail_without context of external contact"}
//
        _this.logMessage += `wx invoke getCurExternalContact:${JSON.stringify(res)}`
        if (res.err_msg == "getCurExternalContact:ok") {
          const userId = res.userId;
          _this.externalUserId = userId;
          console.log("userid:", userId);
        } else {
          //错误处理
          console.log("invoke-getCurExternalContact失败:", res);
          _this.externalUserId = "userId获取失败";
        }
      });
      wx.invoke("getCurExternalChat", {}, function (res) {
        console.log("invoke-getCurExternalChat", res);
//
//{"err_code":2,"err_msg":"getCurExternalChat:fail_without context of external contact"}
//
        _this.logMessage += `wx invoke getCurExternalChat:${JSON.stringify(res)}`
        if (res.err_msg == "getCurExternalChat:ok") {
          const chatId = res.chatId;
          _this.chatId = chatId;
          _this.getUserIdByGroupId();
          console.log("chatId:", chatId);
        } else {
          //错误处理
          console.log("invoke-getCurExternalChat失败:", res);
          _this.chatId = false;
          _this.loadingText =
            "获取群聊信息失败,请在企业微信群聊打开";
        }
      });
  },
  fail: function (res) {
    console.log("agentConfig应用注入失败:", res);
  },
});
回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员--Asher
    社区技术运营专员--Asher
    2025-07-25

    企业微信的问题建议到企业微信开发者中心提问:https://developer.work.weixin.qq.com/community/question

    2025-07-25
    有用 1
    回复
登录 后发表内容