iphone web页跳转回app应用处理

1. 获悉IOS应用的CFBundleURLSchemes(plist文件里面含有)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLName</key>
		<string>com.fanxer.crazylottery</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>demo</string>
		</array>
	</dict>
</array>
</plist>

 

2. javascript的使用

<script type="text/javascript">
var id;
function reback(status){ 
          window.location.href = "demo:"+status;
          if (id  != undefined) {
                window.clearTimeout(id); 
          }
          id = window.setTimeout('windowclose()',3000); 
}
function windowclose(){ 
          window.open('','_self');
          window.close();
}
</script>

 

业务需求是,跳回demo应用后,3秒钟后关闭当前页面

 

3秒退出,解决ios 8.1.1直接关闭,不执行跳转到应用功能

ios 8.1.0 不支持window.close()方法,所有无效

 

3. demo页面

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html>
<head>
<title>demo</title>
<meta http-equiv="Content-Type" name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0;charset=utf-8;application/vnd.wap.xhtml+xml" />
<meta HTTP-EQUIV="pragma" CONTENT="no-cache"/> 
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"/> 
<meta HTTP-EQUIV="expires" CONTENT="0"/> 
</head>
<script type="text/javascript">
var id;
function reback(status){ 
          window.location.href = "demo:"+status;
          if (id  != undefined) {
                window.clearTimeout(id); 
          }
          id = window.setTimeout('windowclose()',3000); 
}
function windowclose(){ 
          window.open('','_self');
          window.close();
}
</script>
<style type="text/css">   
@media not screen and (orientation:portrait){
body{color:#f00;}
}
body,div,p,form{
padding:0;
margin:0;
font-size:18px;
}
.tip-title{
font-size:22px;
font-weight:100;
}
.font-lottery-type{
font-size:25px;
font-weight:100;
margin-bottom:17px;
}
.font-18{
font-size:18px;
font-weight:100;
margin-bottom:10px;
}
.font-20{
font-size:20px;
font-weight:100;
}
body{
padding: 5px 0 2px 0;
line-height:20px;
}
img{
border:none;
vertical-align:-20%;
}
strong{
font-weight:bolder;
}
a{
color:#0077FF;
text-decoration:underline;
}
a:hover{
color:#ffffff;
background-color:#3796FF;
}
input[type="submit"], input[type="reset"], input[type="button"], 
button { -webkit-appearance: none;}
.ap-noline{
line-height:14px;
}
.ap-c-black{
color:#000000;
}
.ap-c-gray{
color:#999999;
}
.ap-c-orange{
color:#ff9900;
}
.ap-c-red{
color:#ff0033;
}
.ap-c-green{
color:#00CC00;
}
.ap-cb-gray{
background-color:#F2F2F2;;
}
.ap-cb-red{
background-color:#9a0000;
}
.ap-a{
color:#ffffff;
line-height:36px;
padding:4px;
height:36px;
}
.ap-b{
color:#000000;
line-height:16px;
padding:4px;
}
.b-hr{
border-top:1px solid #AEAEAE;
}
.ap-hr{
border-bottom:1px solid #AEAEAE;
}
input.checkbox,input[type=checkbox],input[type=radio]{
padding:0;
margin-right:4px;
cursor:pointer;
vertical-align:middle;
vertical-align:-20%;
}
.ap-left{
margin-left: 5px;
line-height:18px; 
}
.ap-top{
//                border:1px solid #000000;
//                margin-left: 2px;
height:100%;
width:320px;
}
.btn{
font-size:18px;
width:140px;
height:36px;
background-color:#9a0000;
color:#ffffff;
border:0;
}
.title-po{
position: relative;
  top: -20%;
}
</style>   
<body>
<div align="center">
     <div class="ap-top" style="text-align:left;">
          <div class="ap-a  ap-hr ap-cb-red tip-title" align="center">
             Demo例子
          </div>
          <div class="ap-b ap-left ap-noline" 
style="height:70px;vertical-align:middle;text-align:position;" >
          <span class="ap-c-green font-lottery-type title-po" >欢迎您使用,Demo例子</span><br />
          </div>
          
          <div class="b-hr" />
          <div class="ap-b ap-left ap-noline">
          <br />
          Demo test<br /><br />
          <span class="ap-c-green"></span><br />
          <div  align="center"> 
          <span align="center"> <input type="button" value="返回Demo" οnclick="javascript:reback(1);"
 class="btn" style="background-color:#d9d9d9;border:1px solid #aaaaaa;color:#333333"  /> </span>&nbsp;
          <span align="center"> <input type="button" value="继续Demo的某个页" 
class="btn" οnclick="javascript:reback(2);"  /> </span><br/>
        </div>
          </div>
     </div>
     </div>

</body>
</html>

 

 

 

### Unity 中实现 App 面之间跳转的方法 在 Unity 开发中,面间的跳转可以通过多种方式来实现。具体取决于目标平台以及开发的需求场景。 #### 使用 `SceneManager` 切换场景 Unity 提供了一个强大的工具——Scene Management API 来管理不同场景之间的切换。通过加载不同的场景文件可以轻松完成面间跳转的功能。以下是基本的代码示例: ```csharp using UnityEngine; using UnityEngine.SceneManagement; public class SceneSwitcher : MonoBehaviour { public void LoadNextScene() { int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; if (currentSceneIndex + 1 < SceneManager.sceneCountInBuildSettings) SceneManager.LoadScene(currentSceneIndex + 1); } } ``` 上述代码展示了如何基于当前活动场景索引来加载下一个场景[^1]。 #### 使用 URL Scheme 或 Deep Linking 跳转至外部应用 如果需要从 Unity 应用程序内部跳转到其他应用程序(例如 App Store、淘宝等),则通常会采用 URL Scheme 或 Deeplinking 技术。下面是一个例子展示如何调用 iOSApp Store 并引导用户撰写评论: ```csharp #if UNITY_IPHONE || UNITY_EDITOR || UNITY_IOS const string APP_ID = "1361497551"; var url = string.Format( "itms-apps://itunes.apple.com/cn/app/id{0}?mt=8&action=write-review", APP_ID ); Application.OpenURL(url); #endif ``` 这段脚本仅适用于 iOS 设备,并且依赖于有效的 iTunes 链接结构[^2]。 对于 Android 和其他情况下的跨应用导航,则可能涉及更多复杂的配置过程,比如定义自定义协议或者利用 Intent 系统[^3]。 #### WebGL 上的网重定向 当项目被导出为 Web 版本时,还可以考虑直接修改浏览器地址栏的方式来进行面转换操作。这里给出一段针对 WebGL 构建类型的简单实例说明: ```javascript mergeInto(LibraryManager.library, { OpenPage: function (str) { let pageUrl = Pointer_stringify(str); window.location.href = pageUrl; }, }); ``` 此函数接受字符串参数作为新网址输入源,在执行过程中改变窗口位置属性从而达到重新定位的目的[^4]。 综上所述,根据实际应用场景的不同可以选择合适的技术手段去达成目的。无论是本地资源还是远程服务都可以找到相应的解决方案加以解决。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值