杀死一只知更鸟 - uniapp
type: channel
link: https://shangjidong.com/tag/uniapp/
items: uniapp判断当前环境是安卓还是苹果
items: uniapp H5与原生APP 安卓端和苹果端交互方法

uniapp判断当前环境是安卓还是苹果
type: item
date: 2024-01-30T10:06:21+08:00
description: uniapp判断当前环境是安卓还是苹果：const UA = navigator.userAgent; app.provide('isIOS', !!UA.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)); app.provide( 'isAndroid', UA.indexOf('Android') > -1 || UA.indexOf('Linux') > -1 );

uniapp H5与原生APP 安卓端和苹果端交互方法
type: item
date: 2024-01-30T09:57:56+08:00
description: 与苹果ios交互动作方法名称 shareFriendsPoster ，还有参数传给ios，如果没有参数需要传nullconst sharePosterConfigIOS = { posterImgUrl: unref(poster), drawId: id, activeCode: 'customer_coupon' } window.webkit.messageHandlers.shareFriendsPoster.postMessage(JSON.stringify(sharePosterConfigIOS))与安卓交互window.supportJs.shareFriendsPoster(unref(poster), unref(id),sharePosterConfig.activeCode)