Skip to content

Commit

Permalink
feat(android): init/load optimization toggles, default true, override…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed Jun 24, 2022
1 parent 1f17e15 commit 05cbc7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RNGoogleMobileAdsExample/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"android_app_id": "ca-app-pub-3940256099942544~3347511713",
"ios_app_id": "ca-app-pub-3940256099942544~1458002511",
"delay_app_measurement_init": false,
"optimize_initialization": true,
"optimize_ad_loading": true,
"user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
}
}
8 changes: 7 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ apply from: file("./app-json.gradle")

def appJSONGoogleMobileAdsAppIDString
def appJSONGoogleMobileAdsDelayAppMeasurementInitBool = false
def appJSONGoogleMobileAdsOptimizeInitializationBool = true
def appJSONGoogleMobileAdsOptimizeAdLoadingBool = true

if (rootProject.ext.googleMobileAdsJson) {
appJSONGoogleMobileAdsAppIDString = rootProject.ext.googleMobileAdsJson.getStringValue("android_app_id", "")
appJSONGoogleMobileAdsDelayAppMeasurementInitBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("delay_app_measurement_init", false)
appJSONGoogleMobileAdsOptimizeInitializationBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_initialization", true)
appJSONGoogleMobileAdsOptimizeAdLoadingBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("optimize_ad_loading", true)
}

if (!appJSONGoogleMobileAdsAppIDString) {
Expand All @@ -80,7 +84,9 @@ android {
multiDexEnabled true
manifestPlaceholders = [
appJSONGoogleMobileAdsAppID : appJSONGoogleMobileAdsAppIDString,
appJSONGoogleMobileAdsDelayAppMeasurementInit: appJSONGoogleMobileAdsDelayAppMeasurementInitBool
appJSONGoogleMobileAdsDelayAppMeasurementInit: appJSONGoogleMobileAdsDelayAppMeasurementInitBool,
appJSONGoogleMobileAdsOptimizeInitialization : appJSONGoogleMobileAdsOptimizeInitializationBool,
appJSONGoogleMobileAdsOptimizeAdLoading : appJSONGoogleMobileAdsOptimizeAdLoadingBool
]
}
lintOptions {
Expand Down
6 changes: 6 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
<meta-data
android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
android:value="${appJSONGoogleMobileAdsDelayAppMeasurementInit}"/>
<meta-data
android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
android:value="${appJSONGoogleMobileAdsOptimizeInitialization}"/>
<meta-data
android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
android:value="${appJSONGoogleMobileAdsOptimizeAdLoading}"/>
</application>
</manifest>

0 comments on commit 05cbc7a

Please sign in to comment.