Skip to content

快速接入

1、安装快应用广告 SDK

在快应用项目根目录下安装广告 SDK 资源包,每次发布快应用前可更新包版本,新版本中广告体验更好、功能更丰富。

sh
npm install https://quickapp-sdk.vivo.com.cn/file/sdk/vad-sdk-1.1.0.tgz -S

2、下载快应用广告 demo,拷贝广告页面

点击下载广告 demo

下载快应用广告 demo,解压后将AdLanding文件夹拷贝到您的快应用项目 src/路径下

并在 manifest.json 文件中配置 page 信息。

3、manifest.json 配置

3.1、 路径配置

json
"router": {
    "entry": "Vad/AdOpen", // 开屏广告页面
    "pages": {
        "Vad/AdOpen": {    // 开屏广告页面
            "component": "index"
        },
        "Vad/AdLanding": {   // 广告落地页
            "component": "index"
        }
    }
},

3.2、 和页面配置

json
"display": {
    "titleBarBackgroundColor": "#f2f2f2",
    "titleBarTextColor": "#414141",
    "pages": {
      "Home": {
        "fullScreen": false,
        "titleBar": true,
        "statusBarImmersive": true,
        "titleBarText": "首页",
        "menu": true,
        "menuBarData": {
          "menuBar": true
        }
      },
      "Vad/AdOpen": {
        "fullScreen": true,
        "titleBar": false,
        "statusBarImmersive": true,
        "menu": false,
        "menuBarData": {
          "menuBar": false
        }
      },
      "VadDemo/AdFeed": {
        "fullScreen": false,
        "titleBar": true,
        "statusBarImmersive": true,
        "titleBarText": "信息流",
        "menu": true,
        "menuBarData": {
          "menuBar": true
        }
      }
    }
  }

3.3、 添加接口权限

json
"features": [
  { "name": "system.cipher"},
  {"name": "system.shortcut"},
  {"name": "system.prompt"},
  {"name": "system.network"},
  {"name": "system.router"},
  {"name": "system.fetch"},
  {"name": "system.webview"},
  {"name": "system.request"},
  {"name": "system.device"},
  {"name": "system.package"},
  {"name": "system.storage"},
  {"name": "service.account"},
  {"name": "system.file"},
  {"name": "system.sensor"},
  {"name": "system.vibrator"},
  {"name": "system.image"},
  {"name": "system.geolocation"},
  {"name": "system.battery"},
  {"name": "system.brightness"},
  {"name": "system.volume"}
]

4、初始化广告模块

在项目的 app.ux 入口文件中引入广告 SDK。

js
import VAD_SDK from 'vad-sdk';
export default {
  onCreate() {
    try {
      new VAD_SDK(this);
    } catch (error) {
      console.error('vadsdk error', error)
    }
}};

5、全局配置

5.1 过滤系统能力

快应用调用系统能力 api 获取相关信息时,部分接口需授权提示,可配置忽略该能力。

过滤枚举类型必填说明
geolocationstring获取地理位置 geolocation.getLocation(OBJECT)
imeistring设备标识 device.getId(OBJECT)
simstring获取 Sim 卡的运营商信息 network.getSimOperators(OBJECT)
js
new VAD_SDK(this, {
  // 所有手机都生效
  global: {
    exclude: ["imei"],
  },
  // 华为手机都生效
  huawei: {
    exclude: ["geolocation"],
  },
  xiaomi: {},
  oppo: {},
  honor: {},
});

6、创建广告位

vivo 广告联盟平台创建快应用广告位