From 2a331a60b72d00dd308e47f369073a9bb81b6f80 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Wed, 1 Jun 2022 18:36:55 -0700 Subject: [PATCH 01/13] Update env file ID var name and help text for consistency with other repos --- .../marketing/edge/identity/app/EdgeIdentityApplication.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1651d89f..c7adec93 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 @@ -20,8 +20,8 @@ import com.adobe.marketing.mobile.edge.consent.Consent import com.adobe.marketing.mobile.edge.identity.Identity class EdgeIdentityApplication : Application() { - // Add your app environment id to configure the SDK from your Data Collection mobile property - private var APP_ENVIRONMENT_ID: String = "yourAppId" + // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI + private var ENVIRONMENT_FILE_ID: String = "yourAppId" override fun onCreate() { super.onCreate() @@ -36,7 +36,7 @@ class EdgeIdentityApplication : Application() { Assurance.registerExtension() MobileCore.start { - MobileCore.configureWithAppID(APP_ENVIRONMENT_ID) + MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID) } } } From 662e6a053b6480e8b0e5be24dc99a6ebade0583c Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Fri, 3 Jun 2022 13:26:50 -0700 Subject: [PATCH 02/13] Create api reference for setAdvertisingIdentifier --- Documentation/api-reference.md | 137 +++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 Documentation/api-reference.md diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md new file mode 100644 index 00000000..292a464b --- /dev/null +++ b/Documentation/api-reference.md @@ -0,0 +1,137 @@ +# Adobe Experience Platform Identity for Edge Network Extension - Android + +## Prerequisites + +Refer to the [Getting Started Guide](getting-started.md) + +## API reference + +| APIs | +| ---------------------------------------------- | +| [setAdvertisingIdentifier](#setAdvertisingIdentifier) | + +------ + +### setAdvertisingIdentifier + +When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ namespace. If the API is called with the empty string (`""`), `null`, or the nil UUID values, the GAID is removed from the XDM Identity Map (if previously set). + +The GAID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall. + +> **Warning** +> In order to enable collection of the user's current advertising tracking authorization selection for the provided advertising identifier, you need to install and register the [AEPEdgeConsent](https://aep-sdks.gitbook.io/docs/foundation-extensions/consent-for-edge-network) extension and update the [AEPEdge](https://aep-sdks.gitbook.io/docs/foundation-extensions/experience-platform-extension) dependency to minimum 1.4.1. + +> **Note** +> These examples require Google Play Services to be configured in your mobile application, and use the Google Mobile Ads Lite SDK. For instructions on how to import the SDK and configure your `ApplicationManifest.xml` file, see [Google Mobile Ads Lite SDK setup](https://developers.google.com/admob/android/lite-sdk). + +> **Note** +> These are just implementation examples. For more information about advertising identifiers and how to handle them correctly in your mobile application, see [Google Play Services documentation about AdvertisingIdClient](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient). + +#### Java + +##### Syntax +```java +public static void setAdvertisingIdentifier(final String advertisingIdentifier); +``` + +##### Example +```java +... +@Override +public void onResume() { + super.onResume(); + ... + new Thread(new Runnable() { + @Override + public void run() { + String advertisingIdentifier = null; + + try { + AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); + if (adInfo != null) { + if (!adInfo.isLimitAdTrackingEnabled()) { + advertisingIdentifier = adInfo.getId(); + } else { + MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "Limit Ad Tracking is enabled by the user, cannot process the advertising identifier"); + } + } + + } catch (IOException e) { + // Unrecoverable error connecting to Google Play services (e.g., + // the old version of the service doesn't support getting AdvertisingId). + MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "IOException while retrieving the advertising identifier " + e.getLocalizedMessage()); + } catch (GooglePlayServicesNotAvailableException e) { + // Google Play services is not available entirely. + MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "GooglePlayServicesNotAvailableException while retrieving the advertising identifier " + e.getLocalizedMessage()); + } catch (GooglePlayServicesRepairableException e) { + // Google Play services is not installed, up-to-date, or enabled. + MobileCore.log(LoggingMode.DEBUG, "ExampleActivity", "GooglePlayServicesRepairableException while retrieving the advertising identifier " + e.getLocalizedMessage()); + } + + MobileCore.setAdvertisingIdentifier(advertisingIdentifier); + } + }).start(); +} +``` + +#### Kotlin + +##### Syntax +```kotlin +public fun setAdvertisingIdentifier(advertisingIdentifier: String) +``` +##### Example +
+ import ... + +```kotlin +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 +``` +
+ +```kotlin +suspend fun getGAID(applicationContext: Context): String { + var adID = "" + try { + val idInfo = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext) + if (idInfo.isLimitAdTrackingEnabled) { + Log.d("ExampleActivity", "Limit Ad Tracking is enabled by the user, setting ad ID to \"\"") + return adID + } + Log.d("ExampleActivity", "Limit Ad Tracking disabled; ad ID value: ${idInfo.id}") + adID = idInfo.id + } catch (e: GooglePlayServicesNotAvailableException) { + Log.d("ExampleActivity", "GooglePlayServicesNotAvailableException while retrieving the advertising identifier ${e.localizedMessage}") + } catch (e: GooglePlayServicesRepairableException) { + Log.d("ExampleActivity", "GooglePlayServicesRepairableException while retrieving the advertising identifier ${e.localizedMessage}") + } catch (e: IOException) { + Log.d("ExampleActivity", "IOException while retrieving the advertising identifier ${e.localizedMessage}") + } + Log.d("ExampleActivity", "Returning ad ID value: $adID") + return adID +} +``` +Call site: +
+ import ... + +```kotlin +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +``` +
+ +```kotlin + // Create background coroutine scope to fetch ad ID value +val scope = CoroutineScope(Dispatchers.IO).launch { + val adID = sharedViewModel.getGAID(context.applicationContext) + Log.d("ExampleActivity", "Sending ad ID value: $adID to MobileCore.setAdvertisingIdentifier") + MobileCore.setAdvertisingIdentifier(adID) +} +``` \ No newline at end of file From 650a0453fa83c8f5415053a471cdc179f8cd9080 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Fri, 3 Jun 2022 13:35:30 -0700 Subject: [PATCH 03/13] Add API arg description --- Documentation/api-reference.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md index 292a464b..e0020c38 100644 --- a/Documentation/api-reference.md +++ b/Documentation/api-reference.md @@ -33,7 +33,7 @@ The GAID is preserved between app upgrades, is saved and restored during the sta ```java public static void setAdvertisingIdentifier(final String advertisingIdentifier); ``` - +- _identifier_ is a string that provides developers with a simple, standard system to continue to track the Ads through their apps. ##### Example ```java ... @@ -80,6 +80,7 @@ public void onResume() { ```kotlin public fun setAdvertisingIdentifier(advertisingIdentifier: String) ``` +- _identifier_ is a string that provides developers with a simple, standard system to continue to track the Ads through their apps. ##### Example
import ... From 2280aa34772d11a88cf2ea86c431e3e284666273 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Sat, 4 Jun 2022 19:57:40 -0700 Subject: [PATCH 04/13] Add more context for key terms --- Documentation/api-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md index e0020c38..bafc0e6f 100644 --- a/Documentation/api-reference.md +++ b/Documentation/api-reference.md @@ -14,7 +14,7 @@ Refer to the [Getting Started Guide](getting-started.md) ### setAdvertisingIdentifier -When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ namespace. If the API is called with the empty string (`""`), `null`, or the nil UUID values, the GAID is removed from the XDM Identity Map (if previously set). +When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ (Google Advertising ID) namespace. If the API is called with the empty string (`""`), `null`, or the nil [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) values, the GAID is removed from the XDM Identity Map (if previously set). The GAID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall. From c6beff34e7f81a3b92132c0fee1577c8e12fd5f2 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Mon, 6 Jun 2022 14:07:26 -0700 Subject: [PATCH 05/13] Update wording for all-zeros case Update min version requirement --- Documentation/api-reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md index bafc0e6f..8b00ac25 100644 --- a/Documentation/api-reference.md +++ b/Documentation/api-reference.md @@ -14,12 +14,12 @@ Refer to the [Getting Started Guide](getting-started.md) ### setAdvertisingIdentifier -When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ (Google Advertising ID) namespace. If the API is called with the empty string (`""`), `null`, or the nil [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) values, the GAID is removed from the XDM Identity Map (if previously set). +When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ (Google Advertising ID) namespace. If the API is called with the empty string (`""`), `null`, or the all-zeros [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) string values, the GAID is removed from the XDM Identity Map (if previously set). The GAID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall. > **Warning** -> In order to enable collection of the user's current advertising tracking authorization selection for the provided advertising identifier, you need to install and register the [AEPEdgeConsent](https://aep-sdks.gitbook.io/docs/foundation-extensions/consent-for-edge-network) extension and update the [AEPEdge](https://aep-sdks.gitbook.io/docs/foundation-extensions/experience-platform-extension) dependency to minimum 1.4.1. +> In order to enable collection of the user's current advertising tracking authorization selection for the provided advertising identifier, you need to install and register the [AEPEdgeConsent](https://aep-sdks.gitbook.io/docs/foundation-extensions/consent-for-edge-network) extension and update the [AEPEdge](https://aep-sdks.gitbook.io/docs/foundation-extensions/experience-platform-extension) dependency to minimum 1.3.2. > **Note** > These examples require Google Play Services to be configured in your mobile application, and use the Google Mobile Ads Lite SDK. For instructions on how to import the SDK and configure your `ApplicationManifest.xml` file, see [Google Mobile Ads Lite SDK setup](https://developers.google.com/admob/android/lite-sdk). From 6fff364eacf44b97e783fab624ed2ef6e0e4c529 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:15:28 -0700 Subject: [PATCH 06/13] Remove UUID reference link; common ID standard Update syntax arg description --- Documentation/api-reference.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md index 8b00ac25..f6c4630a 100644 --- a/Documentation/api-reference.md +++ b/Documentation/api-reference.md @@ -14,7 +14,7 @@ Refer to the [Getting Started Guide](getting-started.md) ### setAdvertisingIdentifier -When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ (Google Advertising ID) namespace. If the API is called with the empty string (`""`), `null`, or the all-zeros [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) string values, the GAID is removed from the XDM Identity Map (if previously set). +When this API is called with a valid advertising identifier, the Identity for Edge Network extension includes the advertising identifier in the XDM Identity Map using the _GAID_ (Google Advertising ID) namespace. If the API is called with the empty string (`""`), `null`, or the all-zeros UUID string values, the GAID is removed from the XDM Identity Map (if previously set). The GAID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall. @@ -30,11 +30,14 @@ The GAID is preserved between app upgrades, is saved and restored during the sta #### Java ##### Syntax + ```java public static void setAdvertisingIdentifier(final String advertisingIdentifier); ``` -- _identifier_ is a string that provides developers with a simple, standard system to continue to track the Ads through their apps. +- _advertisingIdentifier_ is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps. + ##### Example + ```java ... @Override @@ -80,7 +83,8 @@ public void onResume() { ```kotlin public fun setAdvertisingIdentifier(advertisingIdentifier: String) ``` -- _identifier_ is a string that provides developers with a simple, standard system to continue to track the Ads through their apps. +- _advertisingIdentifier_ is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps. + ##### Example
import ... From 33ab2564a92fc8f63718b1b88414e6be6a10ecc5 Mon Sep 17 00:00:00 2001 From: Tim Kim <95260439+timkimadobe@users.noreply.github.com> Date: Tue, 7 Jun 2022 14:49:14 -0700 Subject: [PATCH 07/13] Add button for setting ad ID to empty string Add code block comenting system to ad ID features Add hint log for commented out button functionality Remove env file ID --- code/app/build.gradle | 3 ++- .../edge/identity/app/EdgeIdentityApplication.kt | 2 +- .../edge/identity/app/model/SharedViewModel.kt | 10 +++++++--- .../identity/app/ui/CustomIdentityFragment.kt | 16 ++++++++++++++++ .../main/res/layout/fragment_custom_identity.xml | 7 +++++++ code/app/src/main/res/values/strings.xml | 3 ++- 6 files changed, 35 insertions(+), 6 deletions(-) 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 b1d50947..9e618f44 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,19 @@ 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() { @@ -117,6 +119,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. @@ -145,6 +148,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