javascript - 如何使用回退方法在 Xamarin Forms iOS 中实现深度链接
问题描述
我正在开发Xamarin.Forms
应用程序。在那方面,我们支持重置密码。为此,当单击忘记密码按钮时,我通过电子邮件收到了忘记密码的链接。当用户单击该链接时,如果安装在浏览器中,我们必须导航到我们的应用程序。
在Android
中,此行为运行良好。我们正在使用后备方法。请参考以下代码,
if(userAgentString.indexOf('Android')>0){
window.location="intent://test.com/UV="+UVvalue+"&forgetuserId="+userID+"#Intent;scheme=https;package=com.test.tesApp;S.browser_fallback_url=https://test.com/index.html?UV="+UVvalue+";end";
}
在iOS
中,我面临如下屏幕截图中的错误,
我们正在使用下面的代码,
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var UVvalue = getUrlVars()["UV"];
var userID = getUrlVars()["forgetuserId"];
var PortalValue=getUrlVars()["portal"]
var isBrowserActive=true;
var userAgentString=navigator.userAgent;
var platform=navigator.platform;
$('#lbl12').val(userAgentString);
var htmlelement="<label>"+userAgentString+"</label>";
var body=document.getElementsByTagName('body');
window.setTimeout(function(){
if(isBrowserActive==true && userAgentString.indexOf('iPhone')>1){
window.location.href="https://test.com/index.html?UV="+UVvalue;
}
},3500);
if(platform=="Win32" || platform=="Macintel"){
$('#imgLoader').css({'margin-top':'9%'});
window.location.href="https://test.com/index.cfm?mg=CI.ResetforgetPassword&UV="+UVvalue+"&portal="+PortalValue;
}
function windowClose() {
window.open('','_parent','');
window.close();
}
$(window).blur(function(){
console.log('Window blurred');
isBrowserActive=false;
if(platform!="Win32" || platform!="Macintel"){
}
window.clearTimeout();
//windowClose();
});
if (userAgentString.indexOf('iPhone')>0){
$('#imgLoader').css({'margin-top':'53%'})
window.location.href="testApp://testApp?UV="+UVvalue+"&forgetuserId="+userID;
}
else if(userAgentString.indexOf('Android')>0){
window.location="intent://test.com/UV="+UVvalue+"&forgetuserId="+userID+"#Intent;scheme=https;package=com.test.tesApp;S.browser_fallback_url=https://test.com/index.html?UV="+UVvalue+";end";
}
解决方案
推荐阅读
- lua - 如何从 LUA 表中选择多个随机元素?
- c++ - MS Visual c++“源文件的数量和相应的输出必须匹配”
- javascript - 如何选择单击元素后生成的元素(回调?)?
- javascript - 如果我想为不同的用户进行某些工作流治理,我是否必须将其合并到我的数据模型中?
- java - 除了 CPU 和内存,线程还竞争哪些资源
- django - 使用 django 动态创建文件
- node.js - 如何解决 Angular 12 应用程序创建问题
- javascript - 在我的 Javascript 文件中传播不可交互实例的尝试无效?
- python - 如何在 FastAPI 中建立 WebSocket 安全(wss)连接
- r - R tidytext 图出现垂直而不是水平