m***@163.com
m***@163.com
  • 发布:2023-04-13 17:03
  • 更新:2023-04-13 17:03
  • 阅读:130

【报Bug】wap2app项目,IOS端通过浏览器打开app并跳转链接无法实现,arguments为空

分类:wap2app

产品分类: 其他/wap2app

App下载地址或H5⽹址: https://ide.dcloud.net.cn/build/download/098dd7f0-d9d5-11ed-a850-63655903bb1c

示例代码:
if (window.plus) {  
                plusReady();  
                checkArguments();  
            } else {  
                document.addEventListener('plusready', plusReady, false)  
                document.addEventListener('plusready', checkArguments, false)  
            }  
function plusReady() {  
function checkArguments(){  

        if(plus.runtime.arguments != ""){  
                try{  
    var aj = JSON.parse(plus.runtime.arguments);  
                            // 处理JSON对象aj  
                            alert(aj)  
                        }catch(e){  
                            // 若传入的参数不是JSON格式字符,需处理异常情况  
                            alert("异常处理")  
                        }  
                    }                 
var args= plus.runtime.arguments;  
                if(args){  
                    let index = args.indexOf("url=")  
                    let url = args.slice(index+4)  
                    if(index > -1) {  
                        wap2app.open(url)  
                    } else {  
                        wap2app.open(args)  
                    }  
                    // 处理args参数,如直达到某新页面等  
                }  
            }  
            // 处理从后台恢复  
            document.addEventListener('newintent', function(){  
                console.log("addEventListener: newintent");  
                checkArguments();  
            },false);

操作步骤:
   onShow: function() {  
        console.log('show');  
                alert("show不延迟" + plus.runtime.arguments)  
                setTimeout(()=> {  
                    alert("show延迟0" + plus.runtime.arguments)  
                }, 0)  
                setTimeout(()=> {  
                    alert("show延迟500ms" + plus.runtime.arguments)  
                }, 500)  
                setTimeout(()=> {  
                    alert("show延迟3000" + plus.runtime.arguments)  
                }, 3000)  
    },  
    /**  
     * 当wap2app从前台进入后台,会触发 onHide  
     */  
    onHide: function() {  
        console.log('hide');  
                alert("hide不延迟" + plus.runtime.arguments)  
                setTimeout(()=> {  
                    alert("hide延迟500ms" + plus.runtime.arguments)  
                }, 500)  
    }

预期结果:

在获取arguments时,应该不为空

实际结果:

""

bug描述:

wap2app项目,需要实现浏览器打开app功能,通过hbuilder给出的文档,将代码贴上去之后,安卓端,可以拿取浏览器传输的url并进行跳转,IOS端,在浏览器做了打印有url的参数,通过唤醒点击打开app后,打印arguments未空,没有任何东西。给获取arguments做了延时操作,分别在onshow、onHide、onLaunch中分别做了延时(0ms,500ms,2000ms)获取参数,都无法获取。

2023-04-13 17:03 负责人:无 分享
已邀请:

要回复问题请先登录注册