adjust 上传
This commit is contained in:
parent
1912a9f669
commit
85a247d6fd
|
|
@ -1,11 +1,16 @@
|
|||
package com.gamedog.statisticreporter.adjust
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.adjust.sdk.Adjust
|
||||
import com.adjust.sdk.AdjustAdRevenue
|
||||
import com.adjust.sdk.AdjustAttribution
|
||||
import com.adjust.sdk.AdjustConfig
|
||||
import com.adjust.sdk.LogLevel
|
||||
import com.adjust.sdk.OnAttributionChangedListener
|
||||
import com.adjust.sdk.huawei.BuildConfig
|
||||
import com.ama.core.architecture.BaseApp
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
class AdjustManager private constructor() {
|
||||
|
|
@ -28,10 +33,55 @@ class AdjustManager private constructor() {
|
|||
val environment = if (isDebug) AdjustConfig.ENVIRONMENT_SANDBOX else AdjustConfig.ENVIRONMENT_PRODUCTION
|
||||
val config = AdjustConfig(mAppContext, appToken, environment).apply {
|
||||
setLogLevel(if (isDebug) LogLevel.VERBOSE else LogLevel.WARN)
|
||||
enableSendingInBackground()
|
||||
enableCoppaCompliance()
|
||||
|
||||
onAttributionChangedListener = OnAttributionChangedListener {
|
||||
handleAttributionEvent(it)
|
||||
}
|
||||
}
|
||||
Adjust.initSdk(config)
|
||||
Adjust.enable()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun reportAdRevenueInfo() {
|
||||
val adjustAdRevenue = AdjustAdRevenue("applovin_max_sdk").apply {
|
||||
setRevenue(1.00, "EUR") // ad收益数值及单位
|
||||
setAdImpressionsCount(10) // 展示数量
|
||||
setAdRevenueNetwork("network1") // 渠道来源
|
||||
setAdRevenueUnit("unit1") // ad收入来源单元
|
||||
setAdRevenuePlacement("banner") // 位置
|
||||
addCallbackParameter("key", "url") // 回调地址-一半是自己的数据统计服务器
|
||||
addPartnerParameter("key2", "value2") // 合作合办信息
|
||||
}
|
||||
|
||||
Adjust.trackAdRevenue(adjustAdRevenue)
|
||||
}
|
||||
|
||||
fun reportAttributionInfo() {
|
||||
Adjust.getAttribution {attribution ->
|
||||
// read attribution
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------- PRIVATE ------------------------//
|
||||
private fun handleAttributionEvent(attribution: AdjustAttribution): JSONObject? {
|
||||
try {
|
||||
return JSONObject(attribution.fbInstallReferrer)
|
||||
} catch (e: JSONException) {
|
||||
Log.d("example", e.message!!)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue