Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Application.RequestAdvertisingIdentifierAsync removed?!

Discussion in 'Android' started by Novack, Sep 18, 2020.

  1. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Im using Unity 2020.1.2f1 and Application.RequestAdvertisingIdentifierAsync is returning nothing.

    In the 2020.1.0b14 (from July 2020) changelog I found:

    "Android: Changed: Application.RequestAdvertisingIdentifierAsync does nothing now"

    What does that mean? Why this call was removed from Android?

    Any clarifications appreciated!
     
  2. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    No comments from anyone at Unity?
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Likely to meet privacy concerns by the stores
     
  4. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @JeffDUnity3D thanks for chimming in.

    I understand the idea, but probably should be up to each dev to use the API call or not.

    Not to mention that changing a public API in such an obscure way certainly results in frustration... The docs simply removed Android from the supported plataforms, so had to track among issues and changelogs only to find such a meaningless comment.

    Regardless, whats the reasonging here, shall we expect this to be solved or fixed, or its just as its gonna be?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I believe the stores required us to do that, they inspect the binaries even if you don't use an API
     
  6. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    The advertisingID as the name implies is supposed to be used for advertisement purposes. Lately everyone is concerned about their privacy and companies are making changes to respect that. Unity is not different. The main reason we are removing this API is that it does not belong in the core product. We want to prevent our internal teams as well as our users from accidentally getting sensitive data without realising the implications. This change was done for Android first because Google's Play Store is already rejecting apps in certain categories if they use advertisingID, however it is likely that Application.RequestAdvertisingIdentifierAsync will be removed for other platforms in the future as well. As our documentation states, this API returns false if it's not supported on a certain platform, so you should check for that. Finally if you are implementing an advertising solution yourself, you can use Android API directly to get advertisingID https://developer.android.com/reference/androidx/ads/identifier/AdvertisingIdClient.
     
  7. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Thats not a reason to remove an API call. Simply put, the implications should be expressed in the docs, and if you want, with some warning on the build. Evidently its easier on you to remove it (understandable, but dont expect for us to share your logic on that regard).

    Regardless of any of that, the process in which you decide to remove a feature, leaving us hanging, with total uncertainty regarding why, or if its temporary, etc, has enormous room for improvement.
     
    AlexCome and th_teehah like this.
  8. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    I think the problem here is - the very presence of RequestAdvertisingIdentifierAsync in Unity API flags the app for google that it uses ads even if the app doesn't call that C# function, the java call under that C# function would still exist.
     
  9. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    That makes sense! Thanks for the clarification. @JeffDUnity3D mentioned that, but more like a possibility, so a confirmation definitively helps.

    I appreciate the three of you jumping to the thread, and taking the time to elaborate on the matter.
     
  10. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    95
  11. lucbloom

    lucbloom

    Joined:
    Mar 27, 2020
    Posts:
    42
    Call it from Java directly:

    Code (CSharp):
    1.         public static string GetAndroidAdvertiserId()
    2.         {
    3.             string advertisingID = "";
    4.             try
    5.             {
    6.                 AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
    7.                 AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity");
    8.                 AndroidJavaClass client = new AndroidJavaClass ("com.google.android.gms.ads.identifier.AdvertisingIdClient");
    9.                 AndroidJavaObject adInfo = client.CallStatic<AndroidJavaObject> ("getAdvertisingIdInfo", currentActivity);
    10.      
    11.                 advertisingID = adInfo.Call<string> ("getId").ToString();
    12.             }
    13.             catch (Exception)
    14.             {
    15.             }
    16.             return advertisingID;
    17.         }
     
    Novack likes this.