贴一下sign的代码:
public static String sign(String ticket, String nonceStr, long timeStamp, String url) throws OApiException {
String plain = "jsapi_ticket=" + ticket + "&noncestr=" + nonceStr + "×tamp=" + String.valueOf(timeStamp)
+ "&url=" + url;
try {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
sha1.reset();
sha1.update(plain.getBytes("UTF-8"));
return bytesToHex(sha1.digest());
} catch (NoSuchAlgorithmException e) {
throw new OApiResultException(e.getMessage());
} catch (UnsupportedEncodingException e) {
throw new OApiResultException(e.getMessage());
}
}
private static String bytesToHex(byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
然后我就在js中配置了config,可是dd.device.notification.confirm就是不执行,把config注释掉之后才执行,我猜想是config配置有问题,找了好久就是不知道哪里有问题
dd.config({
agentId:agentId,
corpId: corpId,
timeStamp: timeStamp,
nonceStr:nonceStr,
signature: signature,
jsApiList: ['device.notification.alert', 'device.notification.confirm','device.geolocation.get']
});
dd.ready(function() {
dd.device.notification.confirm({
message: "config还是不对啊!!!",
title: "提示",
buttonLabels: ['z', 'z'],
onSuccess : function(result) {
//onSuccess将在点击button之后回调
/*
{
buttonIndex: 0 //被点击按钮的索引值,Number类型,从0开始
}
*/
},
onFail : function(err) {}
});
});
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。