Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Android Permissions are a bit ridiculous?

Discussion in 'Unity Ads & User Acquisition' started by Eoghan, Jan 26, 2015.

  1. Eoghan

    Eoghan

    Joined:
    Jun 6, 2013
    Posts:
    80
    Currently, Unity Ads requires the following permissions as per the manifest.xml;

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    The first two, entirely understandable for delivering adverts. However, needing to write to external storage.. not so much. I understand this is used to cache videos prior to delivery - but it comes at a cost of the Play Store alerting users that you need access to "All photos and media" on their device. Coupled with the inclusion of requiring net access, it can turn a lot of users off installing your app - especially after high profile events ala "The Fappening" etc.

    Would it not be possible to stream adverts on the fly to users (bandwidth pending), or offer an alternative in simply showing banner adverts without requiring an external cache write?

    The Unity Ads system is extremely easy to integrate, and provides an excellent service (in the limited time I've gotton to work with it), with huge fill rates to boot - but the permissions requests are pretty horrendous, especially if you're an unknown developer.

    Are there any plans for any alternative systems to this in Unity Ads, to prevent having to ask for such potentially invasive device permissions?
     
  2. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    You can publish to Android API 19 where they have tightened security. No doubt it will be further tightened in later APIs. Basically access to any information that is not needed for the game and not kept in the game's private sandbox (like cached ads) and shipped with the game should be explicitly asked for and only when needed.

    In seems the unique device ID and the ads themselves is the only information always used by apps that didn't ship with the app in the case of Unity Ads but that can't be helped and is privatized. Unity Ads don't request private information unless a billable event occurs. And if Unity Ads does request private information, we don't have access to it.

    The Unity Ads guys may feel welcome to correct me if they wish.

    http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE
     
  3. Osirius

    Osirius

    Joined:
    Oct 10, 2014
    Posts:
    47
    Simply delete the "WRITE_EXTERNAL_STORAGE" line, it isn't essential for Unity Ads to function.
    I haven't tested it from an app published on the Play store but removing that line still displays ads and only displays the first 2 permissions when installing manually. The Network State one probably isn't essential either although removing it certainly isn't recommended as I believe Unity Ads use it to determine whether the network speed is good enough to display ads (could be wrong).

    In any case, removing the permission doesn't seem to cause any problems but I'd wait for advice from the Unity Ads staff before doing anything.
     
  4. Eoghan

    Eoghan

    Joined:
    Jun 6, 2013
    Posts:
    80
    Seems like an excellent solution if it works :) I did test it out myself, but didn't have an ad displayed on my device.. but it could also have been a fill rate problem, as I'd been shown a bunch of ads today while testing a few bug fixes.

    Will wait on a staff member to weigh in, and get it updated if that's a suitable solution :)
     
  5. Osirius

    Osirius

    Joined:
    Oct 10, 2014
    Posts:
    47
    Something to note: In the Android "player" settings, I have Write Access set to Internal Only. Not sure if this makes any difference :)

    Here is my AdLoader script that runs at the start of my game for reference:

    Code (csharp):
    1.  
    2. public class AdLoader : MonoBehaviour {
    3.  
    4.     public string gameID = "[GAMEID]";
    5.     public bool disableTestMode;
    6.  
    7.     public string zoneID = null;
    8.     public float timeout = 15f;
    9.  
    10.     private float _startTime = 0f;
    11.     private float _yieldTime = 1f;
    12.  
    13.     void Awake()
    14.     {
    15.         bool enableTestMode = Debug.isDebugBuild && !disableTestMode;
    16.         Debug.Log(string.Format("Initializing Unity Ads for game ID {0} with test mode {1}...",
    17.                                 gameID, enableTestMode ? "enabled" : "disabled"));
    18.         Advertisement.Initialize(gameID, enableTestMode);
    19.     }
    20.  
    21.     IEnumerator Start()
    22.     {
    23.         if (string.IsNullOrEmpty(zoneID)) zoneID = null;
    24.  
    25.         do yield return new WaitForSeconds(_yieldTime);
    26.         while (!Advertisement.isInitialized);
    27.  
    28.         Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");
    29.  
    30.         _startTime = Time.timeSinceLevelLoad;
    31.  
    32.         while (!Advertisement.isReady(zoneID))
    33.         {
    34.             if (Time.timeSinceLevelLoad - _startTime > timeout)
    35.             {
    36.                 Debug.LogWarning("The process for showing ads on load has timed out. " +
    37.                                  "Ad not shown.");
    38.                 yield break;
    39.             }
    40.  
    41.             yield return new WaitForSeconds(_yieldTime);
    42.         }
    43.  
    44.         Debug.Log("Ads are available and ready. Showing ad now...");
    45.  
    46.         Advertisement.Show(null, new ShowOptions
    47.         {
    48.             resultCallback = result =>
    49.             {
    50.                 HandleShowResult(result);
    51.             }
    52.         });
    53.     }
    54.  
    55.     private void HandleShowResult(ShowResult result)
    56.     {
    57.         switch (result)
    58.         {
    59.             case ShowResult.Finished:
    60.                 Debug.Log("The ad was successfully shown.");
    61.                 break;
    62.             case ShowResult.Skipped:
    63.                 Debug.Log("The ad was skipped before reaching the end.");
    64.                 break;
    65.             case ShowResult.Failed:
    66.                 Debug.LogError("The ad failed to be shown.");
    67.                 break;
    68.         }
    69.     }
    70. }
     
  6. unity-nikkolai

    unity-nikkolai

    Unity Technologies

    Joined:
    Sep 18, 2014
    Posts:
    540
    Unity Ads uses a cache folder for ads to be shared between apps that use Unity Ads. This way your device's storage space isn't filled with redundant cached data and your bandwidth usage is minimized. This folder however is written to external storage since system storage is limited, even more so on older devices.
     
    JacPete likes this.
  7. Eoghan

    Eoghan

    Joined:
    Jun 6, 2013
    Posts:
    80
    I understand that much - but the feedback I've been getting in regards to permissions have been a little toxic, to say the least. Would removing that permission still allow ads to operate correctly, albeit at the expense of bandwidth?
     
  8. Osirius

    Osirius

    Joined:
    Oct 10, 2014
    Posts:
    47
    I'm curious as to why it needs to cache data at all.
    I mean, the only reason I can see to cache data is to show the same ad twice, which is completely pointless anyway; If a user clicked on the ad once they're not going to do it again and if they ignored it the first time round a second showing is unlikely to change their mind.
    What exactly is it caching?

    EDIT: Checked out the caching folder and it is indeed saving videos to the device (removing the permission only seems to change the folder to internal storage). Would "Advertisement.allowPrecache = false" stop it from caching ads completely? I'm sure users would prefer a bit of extra bandwidth usage than clogging up all their storage space, internal or external.
     
    Last edited: Jan 30, 2015
  9. unity-nikkolai

    unity-nikkolai

    Unity Technologies

    Joined:
    Sep 18, 2014
    Posts:
    540
  10. Eoghan

    Eoghan

    Joined:
    Jun 6, 2013
    Posts:
    80
    Sorry to reply to this late @unity-nikkolai ; but can I gather from what you're saying above, I can remove the permissions for write access - and from this point going forward, unityads will just attempt to stream the ad on the fly?

    I understand this may cause a higher "skip ad" rate if an advert is buffering/stuttering, but I'd really much rather have a permission-free title, at least until I've more of a known, trusted reputation as a developer. Having one app on the app store and having it immediately ask for read/write access.. I'm generally pretty trusting myself, but that'd even set off a few alarm bells on my end.

    Similarly, why is it that updating PlayerPrefs doesn't require read/write access? Surely this would need to write data to the device?
     
  11. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    We just launched our game and I got a near heartattack when I saw that Unity was requesting access to users' private photos. I somehow missed that on my own testing device apparently. Noone in their right mind accepts such a request. Why is it still part of Unity builds?
     
  12. ChrisEtches

    ChrisEtches

    Joined:
    Jul 26, 2016
    Posts:
    3
    I have just removed the external read / write permission from my game and as far as I can tell, Unity Ads are behaving perfectly.