expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
470 stars 101 forks source link

@config-plugins/react-native-branch retrieve Android AD_ID #237

Open raffiot opened 5 months ago

raffiot commented 5 months ago

Summary

Hello 👋 I'm using "@config-plugins/react-native-branch": "^7.0.0" and "react-native-branch": "^6.1.0" in my expo managed mobile app. However in my branch events (Install, Reinstall, Login etc.) I don’t see any AD_ID attached to the android events in Liveview tab. When I run npx expo prebuild I see the correct parameters:

//./android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
  ...
  <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
  ...
</manifest>
//./android/app/src/proguard-rules.pro
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# react-native-reanimated
-keep class com.swmansion.reanimated.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }

# Add any project specific keep options here:

# @generated begin expo-build-properties - expo prebuild (DO NOT MODIFY)
-keep class com.google.android.gms.** { *; }
-dontwarn com.crashlytics.android.answers.shim.**
-dontwarn com.google.firebase.appindexing.**
-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();
}
# @generated end expo-build-properties

And I have the correct settings in Google Play Console

image

Let me know if you need any additional details. Thanks for your help!

Config Plugin

@config-plugins/react-native-branch

What platform(s) does this occur on?

Android

SDK Version

50.0.14

Reproducible demo

Create an expo managed app with the following configuration

//app.config.ts
export default {
  expo: {
    …
    android: {
      …
      permissions: ['com.google.android.gms.permission.AD_ID']
   }
   plugins: [
     [
       'expo-build-properties',
       {
         android: {
           compileSdkVersion: 34,
           targetSdkVersion: 34,
           minSdkVersion: 31,
           extraProguardRules:
              '-keep class com.google.android.gms.** { *; }\n-dontwarn com.crashlytics.android.answers.shim.**\n-dontwarn com.google.firebase.appindexing.**\n-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {\n com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);\n}\n-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {\njava.lang.String getId();\nboolean isLimitAdTrackingEnabled();\n}', // Used by branch to collect AD_ID
          },
          ios: { deploymentTarget: '13.4' },
        },
    ],
   [
        '@config-plugins/react-native-branch',
        {
          // We add a default value to avoid the alert of empty API key, because the command eas submit fails otherwise
          apiKey:
            process.env.EXPO_PUBLIC_BRANCH_API_KEY ||
            'ignore-empty-apikey-alert',
          iosAppDomain: process.env.EXPO_PUBLIC_BRANCH_IOS_APP_DOMAIN,
        },
    ],
    …
  ]
}
raffiot commented 5 months ago

PS: I checked also on my Android device In Settings>Privacy>Ads and I have an existing Advertising ID ✔️

pgill-rbi commented 3 months ago

@raffiot did you ever get a solution to this?