diff --git a/Documentation/README.md b/Documentation/README.md new file mode 100644 index 00000000..5967d96f --- /dev/null +++ b/Documentation/README.md @@ -0,0 +1,53 @@ +# Advertising identifier + +## Configuration +To enable advertising identifier features in the sample app, follow these steps: +1. Update the value for key `gms_ads_app_id` located in the `secrets.xml` at [aepsdk-edgeidentity-android/code/app/src/main/res/values](../code/app/src/main/res/values/secrets.xml) with a valid Google AdMob app ID. + - See Google's [quick start reference](https://developers.google.com/admob/android/quick-start) on how to get your AdMob app ID. See step 3 of the [Configure your app](https://developers.google.com/admob/android/quick-start#import_the_mobile_ads_sdk) section for a free public test app ID from Google. + - Any real key values in the `secrets.xml` file should **not** be committed to the repository. +2. By default, the ad ID features are commented out in the sample app. To enable these features, uncomment the implemention code using [find and replace all](https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html#replace_search_string_in_project) to replace all instances of: +```java +/* Ad ID implementation +``` +with: +```java +//* Ad ID implementation +``` +Each code block has a pair of block comments wrapped around it to enable this behavior: +```java +/* Ad ID implementation (pt. 1/4) + +/* Ad ID implementation (pt. 1/4) */ +``` + +After replacement it will become: +```java +//* Ad ID implementation (pt. 1/4) + +//* Ad ID implementation (pt. 1/4) */ +``` + +For convenience, these are the default find and replace shortcuts in Android Studio: +[Default shortcuts for find and replace](./assets/find-and-replace-shortcuts.png) + +The shortcut should open a window that looks like the following: +[Example of find and replace](./assets/find-and-replace-all-example.png) +There should be 5 pairs of special comment blocks (10 total matches) across two files: +`app/build.gradle`, `CustomIdentityFragment.kt`, and `SharedViewModel.kt` + +3. With the implementation code and gradle files uncommented with new dependencies, sync the project with the Gradle file changes using: File -> Sync Project with Gradle Files + +[Example of find and replace](./assets/sync-project-gradle-example.png) + +The app should now be properly configured to use advertising identifier features. + +To **disable** these features, follow these steps: +1. [Find and replace](https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html#replace_search_string_in_project) all instances of: +```java +//* Ad ID implementation +``` +with: +```java +/* Ad ID implementation +``` +2. Sync Project with Gradle files using: File -> Sync Project with Gradle Files \ No newline at end of file diff --git a/Documentation/assets/find-and-replace-all-example.png b/Documentation/assets/find-and-replace-all-example.png new file mode 100644 index 00000000..fb7d7942 Binary files /dev/null and b/Documentation/assets/find-and-replace-all-example.png differ diff --git a/Documentation/assets/find-and-replace-shortcuts.png b/Documentation/assets/find-and-replace-shortcuts.png new file mode 100644 index 00000000..9bff8022 Binary files /dev/null and b/Documentation/assets/find-and-replace-shortcuts.png differ diff --git a/Documentation/assets/sync-project-gradle-example.png b/Documentation/assets/sync-project-gradle-example.png new file mode 100644 index 00000000..6557048d Binary files /dev/null and b/Documentation/assets/sync-project-gradle-example.png differ diff --git a/README.md b/README.md index 1ee6fd84..2f5f7753 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,11 @@ The Adobe Experience Platform Edge Identity is a mobile extension for the [Adobe Integrate the Edge Identity extension into your app by including the following in your gradle file's `dependencies`: -``` +```gradle implementation 'com.adobe.marketing.mobile:edgeidentity:1.+' implementation 'com.adobe.marketing.mobile:edge:1.+' implementation 'com.adobe.marketing.mobile:core:1.+' +implementation 'com.adobe.marketing.mobile:edgeconsent:1.+' // Recommended when using the setAdvertisingIdentifier API ``` ### Development @@ -28,12 +29,15 @@ The test app needs to be configured with the following edge extensions before it - Mobile Core (installed by default) - [Edge](https://aep-sdks.gitbook.io/docs/foundation-extensions/experience-platform-extension) - [Edge Identity](https://aep-sdks.gitbook.io/docs/foundation-extensions/identity-for-edge-network) +- [Edge Consent](https://aep-sdks.gitbook.io/docs/foundation-extensions/consent-for-edge-network) (recommended when using the setAdvertisingIdentifier API) **Run demo application** -1. In the test app, set your ENVIRONMENT_FILE_ID in EdgeIdentityApplication.kt. -2. Open `app/res/value/secrets.xml` and follow the instructions to set up the AdMob app ID. This is required for testing with advertising identifiers. -3. Select the `app` runnable with your favorite simulator and run the program. +1. In the test app, set your `ENVIRONMENT_FILE_ID` in `EdgeIdentityApplication.kt`. +2. Select the `app` runnable with the desired emulator and run the program. + +> **Note** +> To enable GAID related advertising identifier features, follow the [documentation](Documentation/README.md#advertising-identifier) for the required setup steps. **View the platform events with Assurance** @@ -67,7 +71,7 @@ try setting the system property 'npm.exec' in the build process to override auto ``` To address this: -- Update Android Studio to the latest version (Bumblebee Patch 1 should address this issue) +- Update Android Studio to the latest version (minimum version Bumblebee Patch 1 should address this issue) - Update the Android Gradle Plugin to the latest version (7.x.x as of this writing) If that does not address the issue, try installing node using the installer and not through homebrew: https://nodejs.org/en/download/ diff --git a/code/app/build.gradle b/code/app/build.gradle index 611d1a6f..c3abf6ab 100644 --- a/code/app/build.gradle +++ b/code/app/build.gradle @@ -63,8 +63,9 @@ dependencies { } implementation 'com.adobe.marketing.mobile:assurance:1+' + /* Ad ID implementation (pt. 1/5) implementation("com.google.android.gms:play-services-ads-lite:20.6.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0-alpha06") + /* Ad ID implementation (pt. 1/5) */ implementation("androidx.multidex:multidex:2.0.1") } diff --git a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/EdgeIdentityApplication.kt b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/EdgeIdentityApplication.kt index c7adec93..74a87125 100644 --- a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/EdgeIdentityApplication.kt +++ b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/EdgeIdentityApplication.kt @@ -21,7 +21,7 @@ import com.adobe.marketing.mobile.edge.identity.Identity class EdgeIdentityApplication : Application() { // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI - private var ENVIRONMENT_FILE_ID: String = "yourAppId" + private var ENVIRONMENT_FILE_ID: String = "" override fun onCreate() { super.onCreate() diff --git a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt index 0f02f8f0..770f0812 100644 --- a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt +++ b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt @@ -11,17 +11,18 @@ package com.adobe.marketing.edge.identity.app.model -import android.content.Context -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import com.adobe.marketing.mobile.edge.identity.AuthenticatedState +/* Ad ID implementation (pt. 2/5) +import android.content.Context +import android.util.Log import com.google.android.gms.ads.identifier.AdvertisingIdClient import com.google.android.gms.common.GooglePlayServicesNotAvailableException import com.google.android.gms.common.GooglePlayServicesRepairableException import java.io.IOException - +/* Ad ID implementation (pt. 2/5) */*/ private const val LOG_TAG = "Shared_View_Model" class SharedViewModel : ViewModel() { @@ -124,6 +125,7 @@ class SharedViewModel : ViewModel() { _authenticatedStateId.value = value } + /* Ad ID implementation (pt. 3/5) /** * Async method that retrieves the ad ID from the `AdvertisingIdClient` (from Google's gms.ads SDK). * Sanitizes ad ID disabled and exceptions to the empty string (`""`), for easy use with `MobileCore` ad ID APIs. @@ -152,6 +154,7 @@ class SharedViewModel : ViewModel() { Log.d(LOG_TAG, "Returning ad ID value: $adID") return adID } + /* Ad ID implementation (pt. 3/5) */*/ // Models for Multiple Identities View diff --git a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/CustomIdentityFragment.kt b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/CustomIdentityFragment.kt index 2ded765e..5a3cfebb 100644 --- a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/CustomIdentityFragment.kt +++ b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/CustomIdentityFragment.kt @@ -32,9 +32,11 @@ import com.adobe.marketing.mobile.edge.identity.AuthenticatedState import com.adobe.marketing.mobile.edge.identity.Identity import com.adobe.marketing.mobile.edge.identity.IdentityItem import com.adobe.marketing.mobile.edge.identity.IdentityMap +/* Ad ID implementation (pt. 4/5) import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +/* Ad ID implementation (pt. 4/5) */*/ private const val LOG_TAG = "Custom_Identity_Fragment" private const val ZERO_ADVERTISING_ID = "00000000-0000-0000-0000-000000000000" @@ -108,6 +110,8 @@ class CustomIdentityFragment : Fragment() { Identity.removeIdentity(item, namespace) } + // Advertising identifier features + // Button for Set Ad ID behavior // Sets the advertising identifier set in the corresponding textfield using the MobileCore API root.findViewById