Giter Site home page Giter Site logo

ericyzhu / cordova-plugin-bytedance-union-ad Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 6.85 MB

穿山甲广告 Cordova 插件。

Objective-C 39.79% JavaScript 4.18% Java 56.03%
cordova cordova-plugin cordova-ios cordova-android bytedance bytedance-unionad

cordova-plugin-bytedance-union-ad's Introduction

穿山甲广告 Cordova 插件

平台

  • iOS
  • Android

安装

cordova plugin add cordova-plugin-bytedance-union-ad

配置 App ID

config.xml 中配置以下内容。

<!-- iOS -->
<platform name="ios">
    <preference name="CDVBytedanceUnionAdAppId" value="YOUR_BUAD_IOS_APP_ID"/>
</platform>

<!-- Android -->
<platform name="android">
    <preference name="CDVBytedanceUnionAdAppId" value="YOUR_BUAD_ANDROID_APP_ID"/>
</platform>

使用

当成功安装和配置完成后,您可以通过全局变量 BytedanceUnionAd 来调用支持的广告类型。

类型定义

/**
 * 常规事件对象。
 *
 * @typedef {Object} Event
 * @property {String} type - 事件类型
 */

/**
 * 错误事件对象。
 *
 * @typedef {Object} ErrorEvent
 * @property {String} type - 事件类型
 * @property {Number} code - 错误代码
 * @property {String} message - 错误信息
 */

/**
 * 常规事件回调。
 *
 * @callback EventCallback
 * @param {Event} event
 * @return {void}
 */

/**
 * 错误事件回调。
 *
 * @callback ErrorEventCallback
 * @param {ErrorEvent} event
 * @return {void}
 */

开屏广告

/**
 * 展示广告。
 * 
 * @function BytedanceUnionAd.SplashAd.show
 * @param {String} slotId - 广告位 ID
 * @return {SplashAd} - 返回 SplashAd 实例
 */
BytedanceUnionAd.SplashAd.show(slotId)

/**
 * 监听事件。
 * 
 * @function SplashAd.on
 * @param {String} eventType - 事件类型
 * @param {EventCallback | ErrorEventCallback} callback - 事件回调
 * @return {SplashAd} - 返回 SplashAd 实例
 */
SplashAd.on(eventType, callback)

事件类型

  • show - 广告物料载入成功
  • close - 广告关闭
  • click - 广告被点击
  • skip - 广告跳过按钮被点击
  • error - 广告物料载入失败

激励视频广告

/**
 * 展示广告。
 * 
 * @function BytedanceUnionAd.RewardedVideoAd.show
 * @param {String} slotId - 广告位 ID
 * @param {String} [userId] - 可选。用户 ID
 * @return {RewardedVideoAd} - 返回 RewardedVideoAd 实例
 */
BytedanceUnionAd.RewardedVideoAd.show(slotId, userId)

/**
 * 监听事件。
 * 
 * @function RewardedVideoAd.on
 * @param {String} eventType - 事件类型
 * @param {EventCallback | ErrorEventCallback} callback - 事件回调
 * @return {RewardedVideoAd} - 返回 RewardedVideoAd 实例
 */
RewardedVideoAd.on(eventType, callback)

事件类型

  • show - 广告物料载入成功
  • close - 广告关闭
  • click - 广告被点击
  • skip - 广告跳过按钮被点击
  • play:finish - 视频广告播放完成
  • play:error - 视频广告播放遇到错误
  • verify:error - 服务端验证异步请求失败
  • verify:valid - 服务端验证异步请求成功并验证有效
  • verify:invalid - 服务端验证异步请求成功并验证无效
  • error - 广告物料载入失败

插屏广告

/**
 * 展示广告。
 * 
 * 广告的宽度和高度需要根据设备屏幕尺寸动态计算,如设置不当可能会错位。
 * 
 * @function BytedanceUnionAd.InterstitialAd.show
 * @param {String} slotId - 广告位 ID
 * @param {Number} width - 广告宽度
 * @param {Number} height - 广告高度
 * @return {InterstitialAd} - 返回 InterstitialAd 实例
 */
BytedanceUnionAd.InterstitialAd.show(slotId, width, height)

/**
 * 监听事件。
 * 
 * @function InterstitialAd.on
 * @param {String} eventType - 事件类型
 * @param {EventCallback | ErrorEventCallback} callback - 事件回调
 * @return {InterstitialAd} - 返回 InterstitialAd 实例
 */
InterstitialAd.on(eventType, callback)

事件类型

  • show - 广告物料载入成功
  • close - 广告关闭
  • click - 广告被点击
  • error - 广告物料载入失败或渲染失败

横幅广告

/**
 * 展示广告。
 * 
 * 广告的宽度和高度需要根据设备屏幕尺寸动态计算,如设置不当可能会错位。
 * 
 * @function BytedanceUnionAd.BannerAd.show
 * @param {String} slotId - 广告位 ID
 * @param {Number} width - 广告宽度
 * @param {Number} height - 广告高度
 * @param {String} align - 广告位置。可选值,`top`、`bottom`(默认)
 * @param {Number} interval - 广告轮播间隔时长。单位,秒。默认 30 秒,如设置为 0 则不轮播
 * @return {BannerAd} - 返回 BannerAd 实例
 */
BytedanceUnionAd.BannerAd.show(slotId, width, height, align, interval)

/**
 * 关闭广告。
 * 
 * @function BytedanceUnionAd.BannerAd.show
 * @param {String} slotId - 广告位 ID
 * @return {BannerAd} - 返回 BannerAd 实例
 */
BytedanceUnionAd.BannerAd.hide(slotId)

/**
 * 监听事件。
 * 
 * @function BannerAd.on
 * @param {String} eventType - 事件类型
 * @param {EventCallback | ErrorEventCallback} callback - 事件回调
 * @return {BannerAd} - 返回 BannerAd 实例
 */
BannerAd.on(eventType, callback)

事件类型

  • show - 广告物料载入成功。`show' 方法没有此事件
  • close - 广告关闭
  • click - 广告被点击。`show' 方法没有此事件
  • error - 广告物料载入失败或渲染失败。`show' 方法没有此事件

cordova-plugin-bytedance-union-ad's People

Contributors

ericyzhu avatar

Stargazers

 avatar

Watchers

 avatar  avatar

cordova-plugin-bytedance-union-ad's Issues

在android 平台不能运行

你好,
感谢提供了穿山甲的插件,第一次使用,我的环境是cordova 9 + cordova-android 10.0 全新空项目,使用了其他插件没有问题,但加了这个插件,就会碰到以下问题,不知道该怎么解决,先谢谢了~

/Users/apple/WebstormProjects/test/platforms/android/app/src/main/java/cordova/plugins/bytedanceunionad/SplashActivity.java:17: 错误: 找不到符号
import androidx.annotation.MainThread;
^
符号: 类 MainThread
位置: 程序包 androidx.annotation
/Users/apple/WebstormProjects/test/platforms/android/app/src/main/java/cordova/plugins/bytedanceunionad/SplashActivity.java:104: 错误: 找不到符号
@mainthread
^
符号: 类 MainThread
/Users/apple/WebstormProjects/test/platforms/android/app/src/main/java/cordova/plugins/bytedanceunionad/SplashActivity.java:113: 错误: 找不到符号
@mainthread
^
符号: 类 MainThread
/Users/apple/WebstormProjects/test/platforms/android/app/src/main/java/cordova/plugins/bytedanceunionad/SplashActivity.java:122: 错误: 找不到符号
@mainthread
^
符号: 类 MainThread
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
4 个错误

FAILURE: Build failed with an exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.