Skip to content

BrickSDK

TIP

说明:它是 BrickSDK 的初始化类,主要提供了初始化操作和登录,支付相关的方法调用

initBrick 初始化SDK

初始化宝船 SDK,在应用创建的时候调用

context:应用的上下文

mKey:为你在宝船出海 SDK 平台应用创建后,平台生成的 key

mSecret:为你在宝船出海 SDK 平台应用创建后,平台生成的秘钥

config:sdk 的配置对象

kotlin
/**
 * 在application的onCreate方法中调用,设置key和secret_

 * config brickSdk的配置对象,里面可配置相关第三方的信息例如adjust的沙盒模式与回调等
*/
fun initBrick(
    context: Context,
    mKey: String,
    mSecret: String,
    config: BrickConfig = BrickConfig()
)

方法举例:

kotlin
BrickSDK.initBrick(
    this,
    "de0bc37d0b2efac53bd7088e6979ad16",
    "024e3cfc008cc8dd86f71ca2d72aa591befb0c2e", BrickConfig()
)

BrickConfig

TIP

说明:它是 BrickSDK 初始化的一个配置类,主要配置一些初始化参数

成员变量

BrickConfig


变量
类型
说明
logEnable
布尔值
是否需要打印日志
bindUid

字符串

app 的业务 Id,每个应用对应同一个业务 Id,可为空
onInitBrickSDK
OnInitBrickSDKCallback 接口
初始化 BrickSDK 的回调
isSandBox
布尔值
adjust 是否为沙盒(测试)模式
adjustCallBack
AdjustCallBack 接口
adjust 的回调类

setAdjust 设置 Adjust 初始化参数**

需要传入 adjust 是否为沙盒模式,和 adjust 回调

mIsSandBox:是否为沙盒模式

mAdjustCallBack:adjust 回调

kotlin
/**
 * 设置adjust参数
 */
fun setAdjust(mIsSandBox: Boolean, mAdjustCallBack: AdjustCallBack? = null): BrickConfig {}

方法举例:

kotlin
config.setAdjust(true, object :
    AdjustCallBack {
    override fun onAttributionChanged(attributionModel: attribution?) {
        Log.e(
            "MyApplication",
            "onAttributionChanged ${attributionModel?.adid ?: ""} ${attributionModel?.trackerName ?: ""} ${attributionModel?.trackerToken ?: ""} ${attributionModel?.campaign ?: ""} ${attributionModel?.costCurrency ?: ""} ${attributionModel?.adgroup ?: ""} ${attributionModel?.clickLabel ?: ""} ${attributionModel?.costType ?: ""} ${attributionModel?.fbInstallReferrer ?: ""} ${attributionModel?.network ?: ""}  "
        )
    }

    override fun onFinishedEventTrackingFailed(adjustEventFailureModel: AdjustEventFailure?) {
        Log.e(
            "MyApplication",
            "onFinishedEventTrackingFailed  ${adjustEventFailureModel._toString_()}"
        )
    }

    override fun onFinishedEventTrackingSucceeded(adjustEventSuccessModel: AdjustEventSuccess?) {
        Log.e(
            "MyApplication",
            "onFinishedEventTrackingSucceeded  ${adjustEventSuccessModel._toString_()}"
        )

    }

    override fun onFinishedSessionTrackingFailed(adjustSessionFailureModel: AdjustSessionFailure?) {
        Log.e(
            "MyApplication",
            "onFinishedSessionTrackingFailed  ${adjustSessionFailureModel._toString_()}"
        )

    }

    override fun onFinishedSessionTrackingSucceeded(adjustSessionSuccessModel: AdjustSessionSuccess?) {
        Log.e(
            "MyApplication",
            "onFinishedSessionTrackingSucceeded  ${adjustSessionSuccessModel._toString_()}"
        )
    }
})

使用举例:

kotlin
val config = BrickConfig()
//是否打印日志,可选
config.logEnable = true
//app的业务Id,每个应用对应同一个业务Id,可选
config.bindUid = ""
//初始化BrickSDK错误的回调,可选
config.onInitBrickSDK=object :OnInitBrickSDKCallback{
    override fun onSuccess() {
    }

    override fun onError(error: String) {
    }
}
//是否为沙盒(测试)模式,可选
config.isSandBox=true
val adjustCallback= object :
    AdjustCallBack {
    override fun onAttributionChanged(attributionModel: attributionModel?) {
        Log.e(
            "MyApplication",
            "onAttributionChanged ${attributionModel?.adid ?: ""} ${attributionModel?.trackerName ?: ""} ${attributionModel?.trackerToken ?: ""} ${attributionModel?.campaign ?: ""} ${attributionModel?.costCurrency ?: ""} ${attributionModel?.adgroup ?: ""} ${attributionModel?.clickLabel ?: ""} ${attributionModel?.costType ?: ""} ${attributionModel?.fbInstallReferrer ?: ""} ${attributionModel?.network ?: ""}  "
        )
    }

    override fun onFinishedEventTrackingFailed(adjustEventFailureModel: AdjustEventFailureModel?) {
        Log.e(
            "MyApplication",
            "onFinishedEventTrackingFailed  ${adjustEventFailureModel._toString_()}"
        )
    }

    override fun onFinishedEventTrackingSucceeded(adjustEventSuccessModel: AdjustEventSuccessModel?) {
        Log.e(
            "MyApplication",
            "onFinishedEventTrackingSucceeded  ${adjustEventSuccessModel._toString_()}"
        )

    }

    override fun onFinishedSessionTrackingFailed(adjustSessionFailureModel: AdjustSessionFailureModel?) {
        Log.e(
            "MyApplication",
            "onFinishedSessionTrackingFailed  ${adjustSessionFailureModel._toString_()}"
        )

    }

    override fun onFinishedSessionTrackingSucceeded(adjustSessionSuccessModel: AdjustSessionSuccessModel?) {
        Log.e(
            "MyApplication",
            "onFinishedSessionTrackingSucceeded  ${adjustSessionSuccessModel._toString_()}"
        )
    }
}
//adjust的回调,可选
config.adjustCallBack=adjustCallback
//同时设置adjust的模式和回调,可选
config.setAdjust(true,adjustCallback)
//具体应用
BrickSDK.getInstance().initBrick(
    this,
    "de0bc37d0b2efac53bd7088e6979ad16",
    "024e3cfc008cc8dd86f71ca2d72aa591befb0c2e", config
)

BrickPlatform

TIP

说明:它表示平台来源是哪一个,目前有游客,谷歌和 Facebook

成员变量

BrickPlatform


变量
类型
说明
from
字符串
来源类型

枚举表

错误类型

说明
BrickGuest
0
游客
Google
1
谷歌
Facebook
2
facebook

BrickError

TIP

说明:它是一个用于 BrickSDK中,在实现各个方法过程中可能出现的错误返回给用户的错误对象 方法:

getCode(): Int

获取错误码

kotlin
fun getCode(): Int

getMessage(): String

获取错误信息

kotlin
fun getMessage(): String

BrickSDKCallback

TIP

说明:它是一个用于 BrickSDK 接口调用的常用回调

方法:

onSuccess()

当删除用户成功时,调用的方法

kotlin
fun onSuccess(data: String?)

data:成功后可能会返回的数据

onError(message: String)

在接口调用过程中因为各种原因出现问题导致失败而回调的方法

message:具体的错误原因

kotlin
fun onError()

实现举例:

kotlin
val brickSDKCallback=object : BrickSDKCallback {
    override fun onSuccess(data: String?) {
    }

    override fun onError(message: String) {
    }
}