H5&小程序 SDK 集成文档

H5&小程序 SDK 集成文档

简介

OneID SDK⽀持H5、⼩程序(微信、⽀付宝、字节)和Uni平台。

合法域名配置

使用OneID SDK,需要在小程序后台需要配置合法域名:

https://oneid.gepush.com
https://oneid.getui.net
https://h5-oneid.gepush.com
https://h5-oneid.getui.net

https://c-oneid.gepush.com
https://c-oneid.getui.net
https://h5c-oneid.gepush.com
https://h5c-oneid.getui.net

https://zxid-api.mobileservice.cn
https://msg.cmpassport.com
https://id6.me/gw/preuniq.do
https://nisportal.10010.com:9001
https://nisnmg3.10010.com:38750
https://nisnmg4.10010.com:38750
https://nisbj1.10010.com:38750
https://nisbj2.10010.com:38750
https://nisbj3.10010.com:38750
https://nistj1.10010.com:38750
https://nissd1.10010.com:38750
https://nissd2.10010.com:38750
https://nissd3.10010.com:38750
https://nisheb1.10010.com:38750
https://nisheb2.10010.com:38750
https://nisheb3.10010.com:38750
https://nissh1x1.10010.com:38750
https://nisah2.10010.com:38750
https://nisah1.10010.com:38750
https://nisshh1.10010.com:38750
https://nisjs1.10010.com:38750
https://niszhj1.10010.com:38750
https://niszhj2.10010.com:38750
https://nisfj1.10010.com:38750
https://nishan1.10010.com:38750
https://nisgd1.10010.com:38750
https://nisgd2.10010.com:38750
https://nisgd3.10010.com:38750
https://nisgd4.10010.com:38750
https://nisgx1.10010.com:38750
https://nisqh1.10010.com:38750
https://nishub1.10010.com:38750
https://nishub2.10010.com:38750
https://nishub3.10010.com:38750
https://nishun1.10010.com:38750
https://nishun2.10010.com:38750
https://nishun3.10010.com:38750
https://nisjx2.10010.com:38750
https://nishen1.10010.com:38750
https://nishen2.10010.com:38750
https://nisxz1.10010.com:38750
https://nissc1.10010.com:38750
https://niscq1.10010.com:38750
https://nissh3x1.10010.com:38750
https://nisgz1.10010.com:38750
https://nisgz2.10010.com:38750
https://nisyn1.10010.com:38750
https://nisgs1.10010.com:38750
https://nisnx1.10010.com:38750
https://nisxj1.10010.com:38750
https://nisxj3.10010.com:38750
https://nisjl1.10010.com:38750
https://nisln1.10010.com:38750
https://nisln2.10010.com:38750
https://nishlj1.10010.com:38750
https://enrichgw.10010.com/d93222629f52ec79
https://hap.10010.com/d93222629f52ec79

SDK使用

SDK在浏览器中使用需要引入第三方js

<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/three.js/r128/three.min.js"></script>

建议自行下载放到自己的cdn服务器上使用

应⽤启动时调⽤OneID⽅法,初始化SDK。

import OneID from './gtoneid-min.js'

OneID.init({
    appId: '个推官网生成的appid',
    onSuccess: function (res) {
      console.log('OneID init success', JSON.stringify(res))
    },
    onFailure: function (res) {
      console.log('OneID init failure', res)
    }
})

成功返回后的结果

// 初始化返回结果
{
    "requestId": "xxxxxxxxf0eb4432897d6be2xxxxxxxx",
    "oneAID": "I-xxxxxxxxfae28cfc4c63708xxxxxxxx",//其中oneAid前缀 I-表示是iOS系统,A-表示Android系统(包括当前华为鸿蒙系统),T-表示非iOS和Android系统(如PC端)
}

API说明

OneID.d.ts⽂件如下

declare namespace OneID {
    /**
     * 获取当前SDK版本
     * @returns {string} 当前SDK版本
     */
    function getVersion(): string;

    export function init(obj: {
        /**
         * 个推官网生成的appid
         */
        appId: string,
        /**
         * 初始化成功回调
         * @param res 初始化成功返回的数据
         */
        onSuccess: (res: any) => void,
        /**
         * 初始化失败回调
         * @param res 初始化失败返回的数据
         */
        onFailure: (res: any) => void
    }): void;

    /**
     * 场景查询
     * @param  
     */
    export function queryLBS(obj: {
        onSuccess: (res: any) => void,
        onFailure: (res: any) => void
    }): void;
}

文档中心搜索

技术
咨询

微信扫一扫

随时联系技术支持

在线
咨询