开发者社区> 问答> 正文

钉钉微应用如何打开本地app (Android)

报{“errorMessage”:"not authorized","errorCode":7}
下面是页面的js


$(function() {
            dd.config({
                agentId : '${ROOT.APPID}',
                corpId : '${ROOT.CORPID}',
                timeStamp : '${ROOT.TIMESTAMP}',
                nonceStr : '${ROOT.NONCESTR}',
                signature : '${ROOT.SIGNATURE}',
                jsApiList : [ 'runtime.permission.requestAuthCode',
                        'runtime.permission.requestJsApis',
                        'dd.device.launcher.launchApp',
                        'dd.device.launcher.checkInstalledApps'
                        
                         ]
            });

            dd.ready(function(bridge) {
                dd.runtime.permission.requestAuthCode({
                    corpId : '${ROOT.CORPID}',
                    onSuccess : function(info) {
                        MobileMeetingAction
                                .getDDUserByCode(info.code,aa );
                    },
                    onFail : function(err) {
                        alert("hha" + JSON.stringify(err));
                    }
                });
                    dd.device.launcher.checkInstalledApps({
    apps: ['taobao', 'tmall'], //iOS:应用scheme;Android:应用包名
    onSuccess : function(data) {
      alert(data);
    },
    onFail : function(err) {
    alert("app:" + JSON.stringify(err));
    }
});

            });

            dd.error(function(err) {
                alert("aa" + JSON.stringify(err));
            });

        });
        function aa(data){
          alert("call:"+data);
        }
        function openMail() {
        dd.device.launcher.checkInstalledApps({
    apps: ['cn.mailtech.app'], //iOS:应用scheme;Android:应用包名
    onSuccess : function(data) {
      alert(data);
    },
    onFail : function(err) {
    alert("app:" + JSON.stringify(err));
    }
});
        }
    </script>

展开
收起
老李归来 2016-01-28 10:05:00 19411 0
3 条回答
写回答
取消 提交回答
  • Re钉钉微应用如何打开本地app (Android)
    怎么解决的?能告诉我吗?
    2017-11-20 11:46:32
    赞同 展开评论 打赏
  • 你好,请参考:
    http://ddtalk.github.io/dingTalkDoc/?spm=a3140.7785475.0.0.uWIpZs#q-jsapi权限校验时返回-message-quot-权限校验失败-quot-,errorcode-3

    -------------------------

    你好,看了下你代码。jsApiList : [ 'runtime.permission.requestAuthCode',
                            'runtime.permission.requestJsApis',
                            'dd.device.launcher.launchApp',
                            'dd.device.launcher.checkInstalledApps'
                            
                             ]
                });
    你后面的两个launcher的配置是不对的。把dd.去掉吧。

    2016-01-28 12:21:08
    赞同 展开评论 打赏
  • Re钉钉微应用如何打开本地app (Android)
    经测试,免登认证已成功,执行 dd.device.launcher.checkInstalledApps 失败报not authorized

    -------------------------

    回 2楼识器的帖子
    你好,我参考了例子,我用调试工具获取的signature 已自己生成的对比,是一致的,但是就是在执行 dd.device.launcher.checkInstalledApps报未授权not authorized    errCode:7

    -------------------------

    回 4楼识器的帖子
    按你所说,我把dd 去掉了,还是不可以

    -------------------------

    Re钉钉微应用如何打开本地app (Android)
    为什么我先访问action 签名后回到页面会认证说权限校验失败  
    @RequestMapping(value="/dd/openCoreMail.action")
            public String openCoreMail(HttpServletRequest request,ModelMap model){
                    String url=request.getRequestURL().toString();
                    String querString=request.getQueryString();

                    if(!StringUtils.isEmpty(querString)&&(!querString.equals("null"))){
                            try {
                                    querString=URLEncoder.encode(querString, "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
                            }
                    }else{
                            querString=null;
                    }
                    String result=AuthHelper.getConfig(url,querString);        
                    JSONObject  jobj=JSONObject.fromObject(result);
                    System.out.println(result);
                    Map map =new HashMap();
                    map.put("SIGNATURE", jobj.getString("signature"));
                    map.put("NONCESTR", jobj.getString("nonceStr"));
                    map.put("TIMESTAMP", jobj.getString("timeStamp"));
                    map.put("CORPID", Env.CORP_ID);
                    map.put("APPID", null);
                    model.addAttribute("ROOT",map);
                    return "dingTalk/openCoreMail";
    }



    下面是页面


    <%@ page language="java" contentType="text/html; charset=UTF-8"
            pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://com/hbglobal/taglib/myplug" prefix="Ding"%>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>


    <title>openCoreMail</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    </head>



    <body>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/engine.js"></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/util.js"></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/interface/MobileMeetingAction.js"></script>
            <script src='${pageContext.request.contextPath}/js/jquery-1.11.3.js'></script>
            <script
                    src='${pageContext.request.contextPath}/js/jquery-migrate-1.2.1.min.js'></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/js/dingtalk.js"></script>

            <script type="text/javascript">

                            dd.config({
                                    agentId : '${ROOT.APPID}',
                                    corpId : '${ROOT.CORPID}',
                                    timeStamp : '${ROOT.TIMESTAMP}',
                                    nonceStr : '${ROOT.NONCESTR}',
                                    signature : '${ROOT.SIGNATURE}',
                                    jsApiList : [ 'device.notification.alert',
                                                    'device.notification.confirm',
                                                    'runtime.permission.requestAuthCode',
                                                    'runtime.permission.requestJsApis',
                                                    'device.launcher.launchApp',
                                                    'device.launcher.checkInstalledApps'

                                    ]
                            });




                    dd.error(function(err) {
                                    alert("aa" + JSON.stringify(err));
                            });
                    function aa(data) {
                            alert("call:" + data);
                    }
                    function openMail(data) {
                            dd.device.launcher.launchApp({
                                    app : 'cn.mailtech.app', //iOS:应用scheme;Android:应用包名
                                    onSuccess : function(data) {
                                            //alert(data);

                                    },
                                    onFail : function(err) {
                                            alert("app:" + JSON.stringify(err));
                                    }
                            });
                    }
                    dd.ready(function(bridge) {
                            dd.runtime.permission.requestAuthCode({
                                    corpId : '${ROOT.CORPID}',
                                    onSuccess : function(info) {
                                        openMail(info);
                                            //MobileMeetingAction.getDDUserByCode(info.code, openMail);
                                    },
                                    onFail : function(err) {
                                            alert("hha" + JSON.stringify(err));
                                    }
                            });


                    });
            </script>
    </body>
    </html>
    但是如果我直接不通过action  直接不把页面放在WEB_INF如下却可以,有什么解决办法没

    <%@ page language="java" contentType="text/html; charset=UTF-8"
            pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ page import="com.hbglobal.ding.auth.AuthHelper,
              org.apache.commons.lang.StringUtils,java.net.URLEncoder,
              java.io.UnsupportedEncodingException,com.hbglobal.listener.DingDingListener,
              net.sf.json.JSONObject,com.hbglobal.ding.po.Env" %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>


    <title>openCoreMail</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    </head>



    <body>
    <%

                    String url=request.getRequestURL().toString();
                    String querString=request.getQueryString();
                    System.out.println(url+":"+querString);
                    if(!StringUtils.isEmpty(querString)&&(!querString.equals("null"))){
                            try {
                                    querString=URLEncoder.encode(querString, "UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
                            }
                    }else{
                            querString=null;
                    }
                    String result=AuthHelper.getConfig(url,querString);        
                    JSONObject  jobj=JSONObject.fromObject(result);
                    System.out.println(result);
                    String SIGNATURE= jobj.getString("signature");
                    String NONCESTR=jobj.getString("nonceStr");
                    String TIMESTAMP= jobj.getString("timeStamp");
                    String CORPID= Env.CORP_ID;



    %>
            <a href="javaScript:openMail()">启动范文</a>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/js/dingtalk.js"></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/engine.js"></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/util.js"></script>
            <script type="text/javascript"
                    src="${pageContext.request.contextPath}/dwr/interface/MobileMeetingAction.js"></script>
            <script src='${pageContext.request.contextPath}/js/jquery-1.11.3.js'></script>
            <script
                    src='${pageContext.request.contextPath}/js/jquery-migrate-1.2.1.min.js'></script>


            <script type="text/javascript">
                       $(function(){
                            dd.config({
                                    agentId : '9868138',
                                    corpId : '<%=CORPID%>',
                                    timeStamp : '<%=TIMESTAMP%>',
                                    nonceStr : '<%=NONCESTR%>',
                                    signature : '<%=SIGNATURE%>',
                                    jsApiList : [ 'device.notification.alert',
                                                    'device.notification.confirm',
                                                    'runtime.permission.requestAuthCode',
                                                    'runtime.permission.requestJsApis',
                                                    'device.launcher.launchApp',
                                                    'device.launcher.checkInstalledApps'

                                    ]
                            });

                            });



                    function aa(data) {
                            alert("call:" + data);
                    }
                    function openMail(data) {
                            dd.device.launcher.launchApp({
                                    apps :'cn.mailtech.app' , //iOS:应用scheme;Android:应用包名
                                    onSuccess : function(data) {
                                            alert(data);
                                    },
                                    onFail : function(err) {
                                            alert("app:" + JSON.stringify(err));
                                    }
                            });
                    }
                    dd.ready(function() {
                            dd.runtime.permission.requestAuthCode({
                                    corpId : '<%=CORPID%>',
                                    onSuccess : function(info) {
                                            //MobileMeetingAction.getDDUserByCode(info.code, openMail);
                                    },
                                    onFail : function(err) {
                                            alert("hha" + JSON.stringify(err));
                                    }
                            });


                    });
                    dd.error(function(err) {

                                    alert("aa" + JSON.stringify(err));
                            });
            </script>
    </body>
    </html>







    2016-01-28 10:14:09
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
钉钉小程序——为工作方式插上翅膀 立即下载
钉钉客户端自动化的应用 立即下载
使命必达 —— 钉钉企业级 消息服务的机遇与挑战 立即下载