8***@qq.com
8***@qq.com
  • 发布:2018-07-09 18:50
  • 更新:2018-07-09 19:52
  • 阅读:1575

ios真机调试可以分享,云打包之后分享不成功

分类:HBuilder
iOS

详细问题描述
ios真机调试可以分享,云打包之后分享不成功,ios分享提示此平台暂不支持系统分享功能

重现步骤
[步骤]ios必现
[结果]
[期望]

运行环境
[系统版本] ios 9.3.3
[浏览器版本]
[IDE版本]HBuilder 9.0.8.201806081953

[mui版本]

附件

<div>  
                <div>分享赚存款</div>  
                <div>  
                    <div class="zanweikaiqi">  
                        <div><img src="../../image/dati.png" /></div>  
                        <div>答题红包</div>  
                    </div>  
                    <div id="shareimg" class="zanweikaiqi">  
                        <div><img src="../../image/fenxiang.png" /></div>  
                        <div>分享海报</div>  
                    </div>  
                    <div id="sharelink" class="zanweikaiqi">  
                        <div><img src="../../image/fenxianglianjie.png" /></div>  
                        <div>分享链接</div>  
                    </div>  
                </div>  
            </div>  

mui.plusReady(function() {  
            ws = plus.webview.currentWebview();  
            //关闭splash页面;  
            plus.navigator.closeSplashscreen();  
        })  
        var sharew;  
        var ws = null;  
        /**  
         *分享窗口  
         */  
        function shareWebview(titles,describes,links) {  
            ws = plus.webview.currentWebview();  
            if (sharew) { // 避免快速多次点击创建多个窗口  
                return;  
            }  
            var top = plus.display.resolutionHeight - 134;  
            var href = "share.html";   
            sharew = plus.webview.create(href, "share.html", {  
                width: '100%',  
                height: '154',  
                top: top,  
                scrollIndicator: 'none',  
                scalable: false,  
                popGesture: 'none'  
            }, {  
                shareInfo: {  
                    "href": links,  
                    "title": titles,  
                    "content": describes,  
                    "pageSourceId": ws.id  
                }  
            });  
            sharew.addEventListener("loaded", function() {  
                sharew.show('slide-in-bottom', 300);  
            }, false);  
            // 显示遮罩层    
            ws.setStyle({  
                mask: "rgba(0,0,0,0.5)"  
            });  
            // 点击关闭遮罩层  
            ws.addEventListener("maskClick", closeMask, false);  
        }  
        function closeMask() {  
            ws.setStyle({  
                mask: "none"  
            });  
            //避免出现特殊情况,确保分享页面在初始化时关闭   
            if (!sharew) {  
                sharew = plus.webview.getWebviewById("share.html");  
                sharew = plus.webview.getWebviewById("shareimg.html");  
            }  
            if (sharew) {  
                sharew.close();  
                sharew = null;  
            }  
        }  

$('#sharelink').on('click', function() {  
            $.ajax({  
                url: host + "/userLinks",  
                type: "post",  
                data: {  
                    token: localStorage.getItem("mylogin"),  
                    sharing_type:1  
                },  
                dataType: "json",  
                success: function(res) {  
                    console.log("分享连接:"+JSON.stringify(res))  
                    if(res.code == 1) {  
                        shareWebview(res.datas[0].title,res.datas[0].describe,res.datas[0].link);  
                    } else if(res.code == -2) {  
                        mui.toast(res.msg);  
                        clearlogin('../index.html');  
                    } else {  
                        mui.toast(res.msg);  
                    }  
                },  
                error: function(xhr, ajaxOptions, thrownError) {  
                    mui.toast('分享功能异常,请将此问题反馈给我们,谢谢配合!')  
                    console.log("err:" + thrownError);  
                }  
            });  

        })  

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="UTF-8">  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <title></title>  
        <link href="../../css/mui.min.css" rel="stylesheet" />  
    </head>  

    <body onclick="closeShare();">  
        <div class="mui-content">  
            <img id="pic" src="img/add.png" style="display: none;" />  
        </div>  
        <footer style="position: absolute;bottom: 0px; width:100%;background: white;">  
            <div style="height: 30px; line-height: 30px ;font-family: '黑体'; margin-left:40%; ;margin-top: 50%;">分享链接</div>  
            <ul class="mui-table-view mui-grid-view mui-grid-9" style="height: 110px;">  
                <li onclick="shareHref(1);" class="mui-table-view-cell mui-media">  
                    <img src="../../image/wx.png" width="40" height="40">  
                    <div class="mui-media-body" style="font-size:12px ;">微信</div>  
                </li>  
                <li onclick="shareHref(0);" class="mui-table-view-cell mui-media">  
                    <img src="../../image/wxf.png" width="40" height="40">  
                    <div class="mui-media-body" style="font-size:12px ;">朋友圈</div>  
                </li>  
            </ul>  
        </footer>  
        <input id="sharehref" style="display: none;" class="sharehref" type="url" value="http://www.qq.com" placeholder="请输入要分享的链接地址" />  
        <input id="sharehrefTitle" style="display: none;" class="sharehref" type="text" value="支付新姿势,用花掉的钱赚利息" placeholder="请输入要分享的链接标题" />  
        <input id="sharehrefDes" style="display: none;" class="sharehref" type="text" value="用楚小诚APP支付买单或购物消费,花掉钱可以记录下来赚利息,赶紧来赚钱吧!" />  
    </body>  
    <srcipt src='../../js/jquery-3.3.3.min.js'></srcipt>  
    <script src="../../js/jquery-3.3.1.js"></script>  
    <script src="../../js/mui.js"></script>  
    <script type="text/javascript">  
        mui.init({  
            swipeBack: true //启用右滑关闭功能  
        });  

        var shares=null;  
        var Intent=null,File=null,Uri=null,main=null;  
        // H5 plus事件处理  
        function plusReady(){  
            updateSerivces();  
            if(plus.os.name=="Android"){  
                main = plus.android.runtimeMainActivity();  
                Intent = plus.android.importClass("android.content.Intent");  
                File = plus.android.importClass("java.io.File");  
                Uri = plus.android.importClass("android.net.Uri");  
                main = plus.android.runtimeMainActivity();  
            }  
            var shareInfo = plus.webview.currentWebview().shareInfo;  
            sharehref.value = shareInfo.href;  
            sharehrefTitle.value = shareInfo.title;  
            sharehrefDes.value = shareInfo.content;  
            pageSourceId = shareInfo.pageSourceId;  
            console.log("pageSource:" + pageSourceId);  
        }  
        if(window.plus){  
            plusReady();  
        }else{  
            document.addEventListener("plusready",plusReady,false);  
        }  

        /**  
         *   
         * 更新分享服务  
         */  
        function updateSerivces(){  
            plus.share.getServices( function(s){  
                shares={};  
                for(var i in s){  
                    var t=s[i];  
                    shares[t.id]=t;  
                }  
            }, function(e){  
                outSet("获取分享服务列表失败:"+e.message );  
            } );  
        }  

        /**  
           * 分享操作  
           * @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService)  
           * @param {Boolean} bh 是否分享链接  
           */  
        function shareAction(sb,bh) {  
            if(!sb||!sb.s){  
                console.log("无效的分享服务!");  
                return;  
            }  
            if (plus.os.name !== "Android") {  
                    plus.nativeUI.alert("此平台暂不支持系统分享功能!");  
                    return;  
            }  

            var msg={content:sharehrefDes.value,extra:{scene:sb.x}};  
            if(bh){  
                msg.href=sharehref.value;  
                if(sharehrefTitle&&sharehrefTitle.value!=""){  
                    msg.title=sharehrefTitle.value;  
                }  
                if(sharehrefDes&&sharehrefDes.value!=""){  
                    msg.content=sharehrefDes.value;  
                }  
                msg.thumbs=["_www/logo.png"];  
                msg.pictures=["_www/logo.png"];  
            }else{  
                if(pic&&pic.realUrl){  
                    msg.pictures=[pic.realUrl];  
                }  
            }  
            // 发送分享  
            if ( sb.s.authenticated ) {  
                console.log("---已授权---");  
                shareMessage(msg,sb.s);  
            } else {  
                console.log("---未授权---");  
                sb.s.authorize( function(){  
                        shareMessage(msg,sb.s);  
                    },function(e){  
                        console.log("认证授权失败:"+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(){  
                console.log("分享到\""+s.description+"\"成功! " );  

            }, function(e){  
                console.log( "分享到\""+s.description+"\"失败: "+JSON.stringify(e) );  

            } );  
        }  
        // 分析链接  
        function shareHref(index){  
            var shareBts=[];  
            // 更新分享列表  
            var ss=shares['weixin'];  
            ss&&ss.nativeClient&&(shareBts.push({title:'微信朋友圈',s:ss,x:'WXSceneTimeline'}),  
            shareBts.push({title:'微信好友',s:ss,x:'WXSceneSession'}));  
//          ss=shares['qq'];  
//          ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});  

            shareAction(shareBts[index],true);  
        }  
        mui.back = function() {  
            var sourcePage = plus.webview.getWebviewById(pageSourceId);  
            if (sourcePage) {  
                sourcePage.evalJS("closeMask()");  
            }  
        }  

        function closeShare() {  
            console.log("e:" + event.target.name);  
        }  
    </script>  

</html>

[代码片段]
[安装包]

联系方式
[QQ]85669082
[电话]18162606532

2018-07-09 18:50 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

真机调试是HBuilder应用的信息,而非自己的应用。
建议重新打个包,将失败回调中的信息alert出来,可以更加方便定位问题。感谢配合

代码里面判定了非安卓环境,不会继续往下执行并弹出了提示。

如何正确高效地在社区提问

  • 8***@qq.com (作者)

    应该不存在你说的这个问题,如果你说的问题存在,那android就无法成功分享,但是目前是android没有任何问题,ios就直接提示 此平台暂不支持系统分享功能,我觉得应该是打包之后可能丢了什么,或者云打包缺少什么支持吧

    2018-07-09 18:58

  • Trust

    回复 8***@qq.com:调用的哪个API?上面的代码中,没看到关键代码。

    2018-07-09 19:03

  • 8***@qq.com (作者)

    2个页面的代码都发布出了,你再看看

    2018-07-09 19:10

  • s***@163.com

    请问一下问题解决了没,我这边遇到了同意的问题

    2018-09-06 14:08

  • 5***@qq.com

    请问下怎么解决的,我也遇到这样的问题了。之前都好好的

    2018-11-01 20:43

  • 5***@qq.com

    回复 s***@163.com:你的解决了吗

    2018-11-01 20:43

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