Commit 60ce8266 authored by leichao.gao's avatar leichao.gao

add facebook event

parent dca23978
......@@ -7,6 +7,8 @@ import android.text.TextUtils
import com.applovin.sdk.AppLovinMediationProvider
import com.applovin.sdk.AppLovinSdk
import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import com.facebook.FacebookSdk
import com.facebook.LoggingBehavior
import com.google.android.gms.ads.MobileAds
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.fcm.ActionBroadcast
......@@ -51,6 +53,9 @@ class MyApplication : BaseApplication() {
}
fun initApp() {
FacebookSdk.sdkInitialize(getApplicationContext());
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS);
initNotificationWork()
InstallHelps.init {
if (ConfigHelper.admobTrueMaxFlase == 0) {
......
......@@ -9,12 +9,14 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.facebook.appevents.AppEventsLogger
import com.test.easy.easycleanerjunk.databinding.ActivityMainBinding
import com.test.easy.easycleanerjunk.fragment.HomeFragment
import com.test.easy.easycleanerjunk.fragment.ToolsFragment
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.utils.BarUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import com.test.easy.easycleanerjunk.view.NotifyTips
import com.test.easy.easycleanerjunk.view.PopExitWindow
import com.test.easy.easycleanerjunk.view.RateStarPop
......@@ -81,6 +83,15 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
PopExitWindow.show(this@NewMainActivity)
}
})
val fbhome = SPUtils.getInstance().getInt("fb_home", 0)
if (fbhome == 0) {
val logger = AppEventsLogger.newLogger(this)
logger.logEvent("home")
SPUtils.getInstance().put("fb_home", 1)
}
}
private fun setPage(p: Int) {
......
......@@ -24,6 +24,7 @@ class ConfigBean() {
var dayoutcomeHomePage: Int = 0 //第二次打开到首页开关
var maxShowNotificationCount: Int = 0
var admobTrueMaxFlase: Int = 0
var adRequestCount:Int=100
var adRequestFailCount:Int=20
var adRequestCount: Int = 100
var adRequestFailCount: Int = 20
var facebookAdShowEventCount: Int = 3
}
......@@ -69,6 +69,7 @@ object ComUtils {
SPUtils.getInstance().put("outcomeReturnHomeCount", bean.outcomeReturnHomeCount)
SPUtils.getInstance().put("dayoutcomeHomePage", bean.dayoutcomeHomePage)
SPUtils.getInstance().put("maxShowNotificationCount", bean.maxShowNotificationCount)
SPUtils.getInstance().put("facebookAdShowEventCount", bean.facebookAdShowEventCount)
ConfigHelper.admobTrueMaxFlase=bean.admobTrueMaxFlase
adDisplayInterval = bean.adInterval
maxMultiClick = bean.maxMultiClick
......
......@@ -4,8 +4,11 @@ package com.test.easy.easycleanerjunk.helps.ads;
import android.content.SharedPreferences;
import android.util.Log;
import com.facebook.appevents.AppEventsLogger;
import com.test.easy.easycleanerjunk.MyApplication;
import com.test.easy.easycleanerjunk.helps.BaseApplication;
import com.test.easy.easycleanerjunk.helps.EventUtils;
import com.test.easy.easycleanerjunk.utils.SPUtils;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -40,7 +43,7 @@ public class AdDisplayUtils {
private static final String MAX_AD_REQUEST_COUNT_KEY = "max_ad_request_count"; // 广告请求次数限制的键
private static final String AD_REQUEST_COUNT_KEY = "ad_request_count";
private int adRequestCount = 0; // 当前广告请求次数
public int maxAdRequestCount=0 ; // 当前广告请求次数
public int maxAdRequestCount = 0; // 当前广告请求次数
private AdDisplayUtils() {
currentDate = getCurrentDate();
......@@ -123,6 +126,13 @@ public class AdDisplayUtils {
adDisplayCount = 0;
}
adDisplayCount++;
int max = SPUtils.getInstance().getInt("facebookAdShowEventCount", 3);
if (adClickCount >= max && max != -1) {
AppEventsLogger logger = AppEventsLogger.newLogger(MyApplication.context);
logger.logEvent("ad_show");
SPUtils.getInstance().put("facebookAdShowEventCount", -1);
}
saveAdDisplayCount();
}
......
......@@ -7,6 +7,8 @@ import android.os.CountDownTimer
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isVisible
import com.facebook.appevents.AppEventsConstants
import com.facebook.appevents.AppEventsLogger
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdLoader
......@@ -574,7 +576,13 @@ object AdmobUtils {
)
roasbundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD")
Firebase.analytics.logEvent("Total_Ads_Revenue_001", roasbundle)
taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)//重新清零,开始计算
val logger = AppEventsLogger.newLogger(BaseApplication.context)
val parameters = Bundle()
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD")
logger.logEvent("ad_value",currentTaichiTroasCache.toDouble(),parameters)
} else {
taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", currentTaichiTroasCache)
}
......
......@@ -13,6 +13,8 @@ import com.applovin.mediation.ads.MaxInterstitialAd
import com.applovin.mediation.nativeAds.MaxNativeAdListener
import com.applovin.mediation.nativeAds.MaxNativeAdLoader
import com.applovin.mediation.nativeAds.MaxNativeAdView
import com.facebook.appevents.AppEventsConstants
import com.facebook.appevents.AppEventsLogger
import com.google.firebase.analytics.FirebaseAnalytics
import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.activity.photocompress.photo.CustomDialog
......@@ -613,6 +615,12 @@ object MaxAdUtils {
roasbundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD")///(Required)tROAS事件必须
mFirebaseAnalytics.logEvent("Total_Ads_Revenue_001", roasbundle) // 给Taichi用
taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)//重新清零,开始计算
val logger = AppEventsLogger.newLogger(BaseApplication.context)
val parameters = Bundle()
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD")
logger.logEvent("ad_value",currentTaichiTroasCache,parameters)
} else {
taichiSharedPreferencesEditor.putFloat(
"TaichiTroasCache",
......
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