胡昂
胡昂
  • 发布:2017-11-28 14:53
  • 更新:2017-11-28 14:53
  • 阅读:2322

app 微信分享功能 在ios中失效

分类:HTML5+

app开发了 新闻分享功能。在安卓上测试通过了,然后在ios中一直分享失败。
以下是部分代码

代码在ios真机运行时已经 打印出了 已授权,说明 我填的配置应该是没有问题。不知道问题出在哪里!

/**

  • 分享操作
  • @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService)
  • @param {Boolean} bh 是否分享链接
    */
    function shareAction(sb, msg) {
    if(!sb || !sb.s) {
    mui.toast("无效的分享服务!");
    return;
    }
    msg.extra = {
    scene: sb.x
    };
    // 发送分享
    if(sb.s.authenticated) {
    console.log("---已授权---");
    shareMessage(msg, sb.s);
    } else {
    console.log("---未授权---");
    sb.s.authorize(function() {
    shareMessage(msg, sb.s);
    }, function(e) {
    mui,
    toast("认证授权失败:" + e.code + " - " + e.message);
    });
    }
    }

/**

  • 发送分享消息
  • @param {JSON} msg
  • @param {plus.share.ShareService} s
    /
    function shareMessage(msg, s) {
    console.log(JSON.stringify(msg));
    s.send(msg, function() {
    mui.toast("分享到\"" + s.description + "\"成功! ");
    }, function(e) {
    /
    mui.alert("分享到\"" + s.description + "\"失败: " + JSON.stringify(e));*/
    });
    }

// 分析链接
function shareHref(mag) {
var shareBts = [];
// 更新分享列表
var ss = shares['weixin'];
console.log(JSON.stringify(ss));
ss && ss.nativeClient && (shareBts.push({
title: '微信朋友圈',
s: ss,
x: 'WXSceneTimeline'
}),
shareBts.push({
title: '微信好友',
s: ss,
x: 'WXSceneSession'
}));
console.log(JSON.stringify(shareBts));
// 弹出分享列表
shareBts.length > 0 ? plus.nativeUI.actionSheet({
cancel: '取消',
buttons: shareBts
}, function(e) {
(e.index > 0) && shareAction(shareBts[e.index - 1], mag);
}) : plus.nativeUI.alert('当前环境无法支持分享链接操作!');
}

2017-11-28 14:53 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复