Android/IOS 微信及浏览器(h5)中唤起本地APP,唤起浮层,然后用外部浏览器打开唤起某本地APP
2023-09-11 14:18:07 时间
1 前言
微信点击链接,点击唤起某APP,在微信点开,默认是微信浏览器,点击button唤起,则会先提示浮层,然后用外部浏览器打开即可。
作为记录使用。
2 代码
相关源码如下:
html:
<div class="container"> <div class="main" > <div class="enterBtn" onclick="triggerStart()"> </div> </div> <div class="openTip" id="openTip"> </div> </div>
Javascipt:
function IsIosAndroid(){ if((/android/gi).test(navigator.appVersion)){ return 1; }else if((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)){ return 2; } } function openAndroid() { //appAndroid://a.b.com是某APP唤起的方式 window.location.href ="appAndroid://a.b.com"; } function openIos() { //appios 是某APP唤起的方式 window.location.href = "appios://"; } function is_weixn(){ var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i)=="micromessenger") { return true; } else { return false; } } function triggerStart(){ if(IsIosAndroid()==1){ if(is_weixn()) { document.getElementById("openTip").style.backgroundImage="url(../images/fuceng.png)"; document.getElementById("openTip").style.display='block'; return; } openAndroid(); }else if(IsIosAndroid()==2){ if(is_weixn()) { document.getElementById("openTip").style.backgroundImage="url(../images/fuceng.png)"; document.getElementById("openTip").style.display='block'; return; } openIos(); } }
3 小结
IOS9之前的 唤起方式不太一样,本文的ios系统为IOS10+
相关文章
- [android]android命令行截图
- [Android Pro] 横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用
- [Android Pro] ant 编译android工程
- Android实例-设置消息提醒(XE8+小米2)
- 深挖android low memory killer
- iOS开发UI篇—ios应用数据存储方式(归档)
- Android API之android.provider.ContactsContract.Contacts
- 【IOS-COCOS2D-X 游戏开发之十六】配置你的COCOS2DX项目编译后的ANDROID自动使用(-HD)高清图&设置ANDROID自适应屏幕、缩放比例方法!
- 可能是目前市面上唯一能够支持全平台的RTMP推流组件:Windows、Linux、Android、iOS、ARM
- 【学习总结】IOS系统和Android系统的区别
- 【VLC-Android】Mac下编译vlc-android
- cordova(ios android)蓝牙权限 手机蓝牙开关开启 跳到设置界面
- Android【报错】. lang。android.app ClassCastException。SharedPreferencesImpl不能被强制转换为android.content.Shared
- Android Glide实现高斯模糊
- Android 11.0 设置默认8时区和默认24小时制
- Android自定义控件之四 自定义ViewGroup实现标签云
- Android-shareSDK
- android报错:prebuilts/misc/linux-x86/bison/bison: cannot execute binary file解决(七十六)
- 编译Android VNC Server(pc远程控制android)(四十九)
- android 输入法如何启动流程_Android输入法显示流程
- Android 输入法框架流程整理
- Android 系统休眠唤醒 android-suspend
- 【Android入门】9、用 Retrofit 和 OkHttp 请求网络、JetPack 组件:ViewModel、LifeCycle、LiveData、Room、WorkManager
- Android的java的报错提示:Could not find com.android.tools.build:gradle:4.2.2.
- This project uses AndroidX dependencies, but the ‘android.useAndroidX‘ property is not enabled. Set
- Android中binder,hwbinder,vndbinder之间的关系