更新记录

1.0.0(2026-06-15)


平台兼容性

uni-app(5.07)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android Android插件版本 iOS 鸿蒙
× × × × × × 5.0 1.0.0 × ×
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
× × × × × × × × × × × ×

uni-app x(5.07)

Chrome Safari Android Android插件版本 iOS 鸿蒙 微信小程序
× × 5.0 1.0.0 × × ×

sl-oaid

oaid插件说明

接入安全联盟官方 oaid_sdk_2.8.0.aar 版本的oaid

使用注意事项:
1、购买前请先在自己的项目试用!(重要)
2、购买前请先在自己的项目试用!(重要)
3、需要在 manifest.json 配置文件设置 "enableOAID" : false
4、 assets/supplierconfig.json 配置文件根据 安全联盟官方 说明配置即可

插件使用示例


<script>
/* 
 manifest.json 配置文件 android打包配置 不要打包uni接入的oaid sdk
"android" : {
    "enableOAID" : false,
 */
import {set_log,certSyncFunc,set_cert_path,getOAID,getDeviceIds} from "@/uni_modules/sl-oaid";

function down_cert(c_url) {
return new Promise(function(resolve, reject){
    uni.downloadFile({
        url: c_url,
        success: (res) => {
            console.log('down_cert res', res);
            if (res.statusCode === 200) {
                uni.saveFile({
                    tempFilePath: res.tempFilePath,
                    success: function (res) {
                        console.log('saveFile', res);
                        // 证书本地路径
                        uni.setStorage({
                            key:"sl-oaid-path-cert",
                            data: res.savedFilePath
                        });
                        resolve(res.savedFilePath);
                    },
                    fail(){
                        console.log('saveFile fail');
                        resolve(false);
                    }
                });
            }else{
                resolve(false);
            }
        },
        fail(){
            console.log('down_cert fail');
            resolve(false);
        }
    });
});
}

let is_dow_cert = false, is_cache = false, oaid_time = 0;
getOaid = async function(c_call) {
    let call_obj = {
        complete:function(e){
            clearTimeout(oaid_time);
            oaid_time=0;
            if(c_call.complete){
                c_call.complete(e)
            }
        },
        success: function(res){
            if(res.oaid){
                is_cache = true;
                c_call.success(res)
            }else{
                call_obj.fail(res);
            }
        },
        fail: function(res){
            c_call.fail(res || {"code":-1,"message":'not'})
        }
    };
    // 防止超时
    oaid_time = setTimeout(call_obj.fail, 6000);
    if (getOAID) {
        set_cache(is_cache); // 是否开启缓存,默认开启。避免获取oaid次数过多
        set_log(false); // 是否开启日志,默认开启
        let oaid_path = uni.getStorageSync("sl-oaid-path-cert");
        if(oaid_path){
            oaid_path = 'file://' + plus.io.convertLocalFileSystemURL(oaid_path);
            set_cert_path(oaid_path); // 设置证书
        }
        let cert = certSyncFunc(); // 获取证书信息
        /* 
         {
             type : Valid | Expired | NotYetValid
             cert: true | false  // 证书是否读取成功
             Before: 证书开始时间
             After: 证书过期时间
             SubjectName: 证书信息
         }
         */
        if(!cert['cert'] || cert['type'] != 'Valid'){
            // 下载过证书也是过期的
            if(is_dow_cert){
                console.log('证书 加载失败');
                call_obj.fail(cert);
                return;
            }
            // 下载证书,证书一年申请一次,所以要放在服务器端
            oaid_path = await down_cert(' 证书url地址 ');
            if (oaid_path) {
                is_dow_cert = true;
                oaid_path = 'file://' + plus.io.convertLocalFileSystemURL(oaid_path);
                set_cert_path(oaid_path); // 设置证书
            } else{
                console.log('证书 下载失败');
                call_obj.fail(cert);
                return;
            }
        }
        getOAID(function(res){
        /* 
        getDeviceIds  包含 vaid 和 aaid
         {
             init : "msaoaidsec" | null
             cert: true | false  // 证书是否读取成功
             oaid: 

             vaid: 
             aaid: 
         }
         */
            call_obj.success(res);
            call_obj.complete(res);
        });
    } else {
        plus.device.getOAID(call_obj);
    }
}
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。