Search Unity

NSLocationWhenInUseUsageDescription required for unknown reasons

Discussion in 'iOS and tvOS' started by AbeGellis, Apr 26, 2018.

  1. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    I have kept the description in my app filled since when the option was available in Player Settings just to silence any warnings.

    But because I know I don't use location, I write it like this:

    We currently do not use location in this app. If you see this, something is wrong.

    I recommend you all do the same. ;)

    upload_2020-1-14_22-48-25.png
     
    Starbox likes this.
  2. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,165
    2018.4.15f also face this issue

    And even add the NSLocationAlwaysUsageDescription string into info.plist could not avoid the warning email

    edited : Oh wait, after seeing above comment I just know that there is new setting textbox for usage description from unity itself. I will try set that instead of directly edit info.plist in my postbuildprocessor first
     
    Last edited: Jan 22, 2020
  3. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,165
    Normally I got warning for both `NSLocationWhenInUseUsageDescription` and `NSLocationAlwaysUsageDescription`

    After I set the configuration as @Neonlyte suggest, I still got warning message but it decreased to only `NSLocationAlwaysUsageDescription`
     
  4. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,165
    OK I have totally fix it by manually add UsageDescription in [PostProcessBuild]

    I think it because I use minimum ios SDK as 9.0 so it still require `NSLocationAlwaysUsageDescription`. But unity config only set `NSLocationWhenInUseUsageDescription` for me

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5.  
    6. using UnityEditor.iOS.Xcode;
    7.  
    8. using System.Linq;
    9.  
    10. public class PostBuildProcessor
    11. {
    12.     [PostProcessBuild(101)]
    13.     private static void ProcessPostBuildIOS(BuildTarget buildTarget, string path)
    14.     {
    15.         if(buildTarget != BuildTarget.iOS)
    16.             return;
    17.  
    18.         Debug.Log ("ProcessPostBuildIOS");
    19.  
    20.         // Get plist
    21.         string plistPath = path + "/Info.plist";
    22.         var plist = new PlistDocument();
    23.         plist.ReadFromFile(plistPath);
    24.  
    25.         // Get root
    26.         var rootDict = plist.root;
    27.  
    28.         rootDict.SetString("NSLocationAlwaysUsageDescription","***Any reason you like***");
    29.  
    30.         plist.WriteToFile(plistPath);
    31.     }
    32. }
    33.  
     
  5. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    I don't believe Unity itself has any feature for background location access i.e. LocationAlwaysUsage.
    I would check if there is any plugin that is using location APIs.
     
    Thaina likes this.
  6. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    I got the issue which was NSLocationWhenInUseUsageDescription too. They want us to add some text descriptor in the info.plist file.
    I would be surprised the problem would be so easily solved but it should actually be possible to have this covered from within Unity, like you did, write stuff in those lines and it will automatically be pushed into the build. Will try this.
    Mind you, the ipa went through as far as TestFlight is concerned.
     
  7. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    Is there a better solution for this since in our app we dont need the location...