Commit 696c0bd9 authored by wanglei's avatar wanglei

[归因]归因

parent 0110c796
......@@ -207,4 +207,10 @@ dependencies {
//implementation ('com.pangle.global:ads-sdk:6.5.0.6')
// If you use version 7.1.0.0 and above, it depends on 'pag-sdk'
implementation("com.pangle.global:pag-sdk:7.1.0.4")
//adjust
// https://dev.adjust.com/en/sdk/android
implementation("com.adjust.sdk:adjust-android:5.4.1")
implementation("com.android.installreferrer:installreferrer:2.2")
}
\ No newline at end of file
......@@ -49,7 +49,6 @@
-keep class com.squareup.okhttp.** { *; }
-keep class com.bytedance.sdk.** { *; }
# 保持 Facebook SDK 的类和方法
-keep class com.facebook.** { *; }
......@@ -64,4 +63,19 @@
# public static *** e(...);
#}
-keep class com.bytedance.sdk.** { *; }
\ No newline at end of file
#pangle 防混淆
-keep class com.bytedance.sdk.** { *; }
# Adjust 防混淆
-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }
......@@ -5,6 +5,8 @@ package com.ritoq.quickphone
*Create by SleepDog on 2024-12-24
*/
object GlobalConfig {
//包名
const val PACKAGE_NAME = "com.ritoq.quickphone.rfrc"
......@@ -64,4 +66,6 @@ object GlobalConfig {
inline val ID_PANGLE_BANNER_300X250 get() = "980088196"
inline val ID_PANGLE_BANNER_320X50 get() = "980099802"
inline val ADJUST_TOKEN get() = "4adqi9e957pc"
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ import com.ritoq.quickphone.push.receiver.ScreenStatusReceiver
import com.ritoq.quickphone.ui.batteryinfo.BatteryReceiver.Companion.registerBatteryReceiver
import com.ritoq.quickphone.ui.splash.SplashActivity
import com.facebook.appevents.AppEventsLogger
import com.ritoq.quickphone.business.helper.AdjustUtils
import com.ritoq.quickphone.business.push.receiver.AlarmReceiver.Companion.startAlarm
import com.ritoq.quickphone.business.push.timer.TimerManager.Companion.changeTimer
import com.ritoq.quickphone.business.push.work.RepeatingWorker.Companion.schedulePeriodicWork
......@@ -181,6 +182,8 @@ class MyApplication : Application() {
//初始化sp的配置
NewComUtils.parseConfigBean(spConfig)
AdjustUtils.initAdjust(this)
NewComUtils.requestCfgCallBackMap.put("changeTimer") {
LogEx.logDebug(TAG, "requestCfgCallBackMap changeTimer")
changeTimer()
......
......@@ -13,8 +13,9 @@ data class ConfigBean(
// val vipConfigBean: VipConfigBean = VipConfigBean(),
val noEventKey: List<String> = listOf(),
val getConfigInterval: Int = 4,//请求配间隔小时
var test: Int = 0,
) {
) {
companion object {
var configBean: ConfigBean = ConfigBean()
......
package com.ritoq.quickphone.business.helper
import android.content.Context
import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig
import com.adjust.sdk.LogLevel
import com.ritoq.quickphone.BuildConfig
import com.ritoq.quickphone.GlobalConfig
import com.ritoq.quickphone.business.helper.InstallHelps.installSource
import com.ritoq.quickphone.business.helper.NewComUtils.requestCfg
import com.ritoq.quickphone.utils.AppPreferences
import com.ritoq.quickphone.utils.LogEx
object AdjustUtils {
private val TAG = "AdjustUtils"
/**
* origin 走 应用配置渠道
* channel 走 facebook渠道
*
*/
fun getUserSource(): String {
if (BuildConfig.DEBUG) {
return "origin"
}
var source = "origin"
if (adJustInstallSource == "channel") {
source = "channel"
return source
} else if (adJustInstallSource == "origin") {
return source
} else {
if (installSource == "channel") {
source = "channel"
}
}
return source
}
//用户来源
var adJustInstallSource = ""
get() {
return AppPreferences.getInstance().getString("adJustInstallSource", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("adJustInstallSource", value, true)
}
fun initAdjust(context: Context) {
val environment = if (BuildConfig.DEBUG) {
AdjustConfig.ENVIRONMENT_SANDBOX
} else {
AdjustConfig.ENVIRONMENT_PRODUCTION
}
val config = AdjustConfig(context, GlobalConfig.ADJUST_TOKEN, environment).apply {
setLogLevel(LogLevel.ERROR)
// 设置归因监听
setOnAttributionChangedListener { attribution ->
val network = attribution.network
val isChannel = !network.isNullOrEmpty() && !network.contains("Organic", true)
adJustInstallSource = if (isChannel) "channel" else "origin"
LogEx.logDebug(TAG, "network=$network isChannel=$isChannel")
requestCfg(true)
}
}
LogEx.logDebug(TAG, "initSdk")
Adjust.initSdk(config)
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package com.ritoq.quickphone.business.helper
import com.android.installreferrer.api.InstallReferrerClient
import com.android.installreferrer.api.InstallReferrerStateListener
import com.android.installreferrer.api.ReferrerDetails
import com.ritoq.quickphone.BuildConfig
import com.ritoq.quickphone.MyApplication
import com.ritoq.quickphone.utils.AppPreferences
import org.json.JSONObject
......@@ -15,6 +14,7 @@ object InstallHelps {
private val TAG = "InstallHelps"
var installReferrer = ""
get() {
return AppPreferences.getInstance().getString("install_referrer", field)
......@@ -83,8 +83,8 @@ object InstallHelps {
InstallReferrerClient.InstallReferrerResponse.OK -> {
val response = referrerClient.installReferrer
eventInstallReferrer(response)
setInstallSource(response)
eventInstallReferrer(response)
requestCfg()
}
......
......@@ -11,6 +11,7 @@ import com.ritoq.quickphone.business.helper.InstallHelps.installReferrer
import com.ritoq.quickphone.utils.AppPreferences
import com.ritoq.quickphone.utils.LogEx
import com.google.gson.Gson
import com.ritoq.quickphone.business.helper.AdjustUtils.getUserSource
import okhttp3.Call
import okhttp3.Callback
import okhttp3.OkHttpClient
......@@ -64,7 +65,8 @@ object NewComUtils {
"&vn=${BuildConfig.VERSION_NAME}" +
"&vc=${BuildConfig.VERSION_CODE}" +
"&device=${AppPreferences.getInstance().getString("gid", "")}" +
"&aid=${AppPreferences.getInstance().getString("uuid", "")}"
"&aid=${AppPreferences.getInstance().getString("uuid", "")}" +
"&source=${getUserSource()}"
if (BuildConfig.DEBUG) {
s = "$s&mode=4"
......@@ -93,12 +95,14 @@ object NewComUtils {
return true
}
fun requestCfg() {
fun requestCfg(requestMust: Boolean = false) {
requestCfgIng.set(true)
if (!canRequestCfg()) {
return
if (!requestMust) {
if (!canRequestCfg()) {
return
}
}
val urlPath = getUrl()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment