search
HomeWeb Front-enduni-appHow to get the mobile phone ID in uniapp

The method for uniapp to obtain the mobile phone identification: call the cache method to obtain the mobile phone identification, the code is [Apple system plus.device.getInfo({success: function(e); Android system plus.device.getAAID({success :...】.

How to get the mobile phone ID in uniapp

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

Recommendation (free): uni-app development tutorial

uni-app method to obtain mobile phone identification:

uni-app obtains the unique identifier of the device according to different mobile phone platforms. Since the acquisition method is asynchronous, the current page execution may not be able to obtain it. It is recommended to cache it. Other pages can be obtained by calling the cache, which does not exist. If so, execute the method to get it to make sure you can get it.

//获取客户端ID
getClientId() {
//获取客户端ID和版本号
var clientid = '';
// #ifdef APP-PLUS
// 苹果系统
plus.device.getInfo({
success: function(e) {
clientid = e.uuid;
uni.setStorageSync('clientid', clientid);
},
fail: function(e) {
console.log(e);
}
});
// 安卓系统
plus.device.getAAID({
success: function(e) {
clientid = e.aaid;
console.log(clientid);
uni.setStorageSync('clientid', clientid);
},
fail: function(e) {
console.log(e);
}
});
//老版本、安卓模拟器
if (clientid == '') {
clientid = plus.device.uuid;
uni.setStorageSync('clientid', clientid);
}
// #endif
return clientid;
}

Related free learning recommendations: Programming Video

The above is the detailed content of How to get the mobile phone ID in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.