欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

uniapp 实现App打开另一个App,以微信为例

程序员文章站 2022-06-21 19:46:07
本文主要介绍,uniapp开发,在app中打开新的App,以微信为例。handleGoApp() {if (plus.os.name == 'Android') {//安卓if (plus.runtime.isApplicationExist({//查看安卓系统手机有没有下载这款apppname: 'com.tencent.mm' //微信app云打包的包名})) {//安装了appplus.runtime.openURL(....

本文主要介绍,uniapp开发,在app中打开新的App,以微信为例。

handleGoApp() {
	if (plus.os.name == 'Android') {
		//安卓
		if (
			plus.runtime.isApplicationExist({
				//查看安卓系统手机有没有下载这款app
				pname: 'com.tencent.mm' //微信app云打包的包名
			})
		) {
			//安装了app
			plus.runtime.openURL(
				'weixin://',
				function(res) {
					console.log(res);
				}
			);
		} else {
			//未安装app
			uni.showModal({
				title: '提示',
				content: '您还没有此APP,去下载',
				success: function(res) {
					if (res.confirm) {
						plus.runtime.openURL('https://a.app.qq.com/o/simple.jsp?pkgname=com.tencent.mm', function(res) {
							console.log(res);
						});
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		}
	} else if (plus.os.name == 'iOS') {
		//苹果
		//因为ios查不到B款app在ios系统手机里面,其实下载了,也是检测不到,所以就不检测了
		//直接打开微信app,微信pp没有的话,会进入回调报错,我们在回调去打开下载链接
		plus.runtime.launchApplication(
			{
				action:
					'weixin://'
			},
			function(e) {
				uni.showModal({
					title: '提示',
					content: '您还没有此APP,去下载',
					success: function(res) {
						if (res.confirm) {
							plus.runtime.openURL('https://a.app.qq.com/o/simple.jsp?pkgname=com.tencent.mm', function(res) {
								console.log(res);
							});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		);
	}
},

本文地址:https://blog.csdn.net/qq_38209578/article/details/112821105