更新记录
1.0.7(2024-06-14)
删除相关
1.0.6(2024-06-14)
文档调整
1.0.5(2024-06-14)
更新文档
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 5.0 | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | - | - | - |
获取设备唯一标识 、OAID、AndroidID
一、插件说明
二、代码示例
<template>
<view>
<view class="content">
<text class="hd-btn" @click="obtainDeviceId"> ObtainDeviceId </text>
<text class="hd-btn" @click="getOAID"> getOAID</text>
</view>
<view style="padding: 0rpx 30rpx;margin-top: 30rpx;" v-html="dataResult" />
</view>
</template>
<script>
// #ifdef APP-ANDROID
import { deviceInfo } from '@/uni_modules/hd-deviceId';
import { DeviceldManage, OptionsCallBack, ResultInfo } from "@/uni_modules/hd-deviceId/utssdk/interface.uts"
const deviceInfo = deviceInfo() as DeviceldManage
// #endif
export default {
data() {
return {
title: 'Hello',
dataResult: ''
}
},
methods: {
openPages(url : string) {
uni.navigateTo({
url
});
},
obtainDeviceId() {
let that = this
deviceInfo.obtainDeviceId({
success: function (res) {
let result = res as ResultInfo
let mapObj = result.data as Map<string, any>
let dataResult = "";
mapObj.forEach(function (value : any, key : string) {
dataResult += `<div><span style="color: #0a27b7">${key}: </span><span>${value}</span></div>`;
})
that.dataResult = dataResult;
}
} as OptionsCallBack);
},
getOAID() {
let that = this
deviceInfo.getOAID({
success: function (res) {
let result = res as ResultInfo
let mapObj = result.data as Map<string, any>
let dataResult = "";
mapObj.forEach(function (value : any, key : string) {
dataResult += `<div><span style="color: #0a27b7">${key}: </span><span>${value}</span></div>`;
})
that.dataResult = dataResult;
}
} as OptionsCallBack);
},
obtainDeviceInfo() {
let that = this
deviceInfo.obtainDeviceInfo({
success: function (res) {
let result = res as ResultInfo
let mapObj = result.data as Map<string, any>
let dataResult = "";
mapObj.forEach(function (value : any, key : string) {
dataResult += `<div><span style="color: #0a27b7">${key}: </span><span>${value}</span></div>`;
})
that.dataResult = dataResult;
}
} as OptionsCallBack);
}
}
}
</script>