Search Unity

Remote Config platforms?

Discussion in 'Unity Remote Config' started by Solovykh, Jan 13, 2020.

  1. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    59
    Hey,

    is there a list of platforms that remote config supports somewhere? can't find anything
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The supported platform would include iOS, Android, Windows, Mac and WebGL
     
    Solovykh likes this.
  3. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
    Hi. It seems that unity.platform=='iOS' and unity.platform=='Android' do not work. When I use them as a condition in a Rule of remote config, I always get the default value, not a specified value (which might override the default value). However, when I set, for example, unity.country='US' everything works fine. I use Remote Config 1.2.2 and Unity 2019.3.10f1, Development Environment. Is it a bug?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What devices are you testing on?
     
  5. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
    iPhone 6s, Nexus 5, Nexus 9, Galaxy S4
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, just wanted to make sure you weren't using an emulator. Can you share a screenshot of your rule settings, and your code?
     
  7. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
    Here it is

    Code (CSharp):
    1. using Unity.RemoteConfig;
    2. using UnityEngine;
    3. using Utils;
    4.  
    5. namespace RemoteConfigs
    6. {
    7.     public class RemoteConfigsManager : Singleton<RemoteConfigsManager>
    8.     {
    9.         private struct userAttributes
    10.         {
    11.         }
    12.  
    13.         private struct appAttributes
    14.         {
    15.         }
    16.  
    17.         protected override void Awake()
    18.         {
    19.             base.Awake();
    20.             FetchRemoteConfiguration();
    21.         }
    22.  
    23.         private void FetchRemoteConfiguration()
    24.         {
    25.             if (gameObject.activeSelf)
    26.             {
    27.                 ConfigManager.FetchCompleted += ApplyRemoteSettings;
    28.                 ConfigManager.FetchConfigs(new userAttributes(), new appAttributes());
    29.                 Debug.Log("Fetched remote configs");
    30.             }
    31.         }
    32.  
    33.         private void ApplyRemoteSettings(ConfigResponse configResponse)
    34.         {
    35.             switch (configResponse.requestOrigin)
    36.             {
    37.                 case ConfigOrigin.Default:
    38.                     Debug.Log("No Settings this session; using default values");
    39.                     break;
    40.                 case ConfigOrigin.Cached:
    41.                     Debug.Log("No setting loaded this session; using cached values from a previous session.");
    42.                     break;
    43.                 case ConfigOrigin.Remote:
    44.                     Debug.Log("New Settings loaded this session; update values accordingly");
    45.                     GetSetting();
    46.                     break;
    47.             }
    48.         }
    49.  
    50.         private void GetSetting()
    51.         {
    52.             var setting1 = ConfigManager.appConfig.GetString("Setting1");
    53.             Debug.Log($"We fetched Setting1: {setting1}");
    54.         }
    55.  
    56.         protected override void OnDestroy()
    57.         {
    58.             base.OnDestroy();
    59.             ConfigManager.FetchCompleted -= ApplyRemoteSettings;
    60.         }
    61.     }
    62. }
     

    Attached Files:

  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Ievgen0101 Are you certain your devices aren't retrieving from the Release environment? Remote Config sends settings from the Release environment to any non-development builds.
     
  9. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
    The thing is my release environment is empty. It doesn't have any config or rule. Moreover, when I build I select a development build option.
     

    Attached Files:

    • img3.png
      img3.png
      File size:
      18.4 KB
      Views:
      374
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Ievgen0101 I am seeing the same behavior, we are looking into it now.
     
  12. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
  13. vd_unity

    vd_unity

    Unity Technologies

    Joined:
    Sep 11, 2014
    Posts:
    41
    Hi @Ievgen0101 , thanks for pointing this out.

    We just released new package version with a fix for platform segmentation:
    1.3.2-preview.2 or 1.2.3-preview.1 if you were on 1.2.x version.

    Please let us know if platform segmentation works if you update the package.

    Thanks,
    Vlatko
     
  14. Ievgen0101

    Ievgen0101

    Joined:
    Apr 11, 2019
    Posts:
    9
    @vd_unity Hi Vlatko. I updated remote config to "1.2.3". What I see now is unity.platform=='iOS' and unity.platform=='macOS' work now. However unity.platform=='Android' - doesn't work, at least on my side (tested on several devices which I mentioned earlier in this thread). On Android I always get the default value and never the specified value.
     
  15. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    I've tried it on 1.2.x---1.4.1 and can confirm that unity.platform == "Android" rule doesn't work.
    Specifying Windows works, default config fetching works. But Android rule doesn't work at all.
    (No emulator, build only, on Xiaomi Redmi Note 8)

    Temporary workaround for me that works was to add "platform" field to the "appAttributes" struct:
    Code (CSharp):
    1.    public struct appAttributes {
    2.       public string platform;
    3.    }
    Then assign "platform" via define (this also removes the need to add || for the rule to work with editor) for the appAttributes struct that is passed to FetchConfig method.
    Code (CSharp):
    1. #if UNITY_IOS
    2.          string platform = "iOS";
    3. #else
    4.          string platform = "Android";
    5. #endif
    6.          appAttributes appAttributes = new appAttributes {platform = platform};
    After that - redefine rule as:
    Code (CSharp):
    1. app.platform == "*your_platform*"
     
  16. allenWTF

    allenWTF

    Joined:
    Mar 16, 2018
    Posts:
    8
    Hi! What about Linux? Is it supported there? Thanks!
     
  17. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  18. creepteks

    creepteks

    Joined:
    Jun 2, 2017
    Posts:
    19
    the problem still exists from the mentioned versions up to version 2.0.0. I successfully can retrieve the remote settings when running in the editor or standalone build, but running on android, the retrieved remote config is empty.
    Here is my code:

    Code (CSharp):
    1.        internal static void SelectTestGroup(int option)
    2.         {
    3.             ConfigManager.FetchCompleted += (config) =>
    4.             {
    5.                 string ip;
    6.                 switch (config.requestOrigin)
    7.                 {
    8.                     case ConfigOrigin.Default:
    9.                     case ConfigOrigin.Cached:
    10.                     case ConfigOrigin.Remote:
    11.                         Debug.Log($"settings loaded via {config.requestOrigin} mode; update values accordingly.");
    12.  
    13.                         ip = ConfigManager.appConfig.GetString("backend_ip");
    14.                         Debug.Log($"backend IP: {ip}");
    15.  
    16.                         NakamaConnector.Instance.Initialize(ip);
    17.                         UnityEngine.SceneManagement.SceneManager.LoadScene(1);
    18.                      
    19.                         break;
    20.                 }
    21.             };
    22.  
    23.             string userCustomId;
    24.             // Set the user’s unique ID:
    25.             switch (option)
    26.             {
    27.                 case 1:
    28.                     userCustomId = "test-group-a";
    29.                     break;
    30.  
    31.                 case 2:
    32.                     userCustomId = "test-group-b";
    33.                     break;
    34.  
    35.                 default:
    36.                     userCustomId = "";
    37.                     break;
    38.             }
    39.             ConfigManager.SetCustomUserID(userCustomId);
    40.  
    41.             string platform = "Android";
    42.  
    43.             // Fetch configuration setting from the remote service:
    44.             ConfigManager.FetchConfigs(new UserAttributes(), new AppAttributes() { platform = platform });
    45.         }
    46.     }
    here is the result I get using logcat :
    Code (CSharp):
    1. I/Unity   ( 7043): settings loaded via Remote mode; update values accordingly.
    2. I/Unity   ( 7043): UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    3. I/Unity   ( 7043): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4. I/Unity   ( 7043): UnityEngine.Logger:Log(LogType, Object)
    5. I/Unity   ( 7043): UnityEngine.Debug:Log(Object)
    6. I/Unity   ( 7043): Davaa.Providers.<>c:<SelectTestGroup>b__0_0(ConfigResponse) (at C:\gamedev\davaa\Davaa\Assets\Scripts\Providers\RemoteConfigProvider.cs:18)
    7. I/Unity   ( 7043): Unity.RemoteConfig.<>c__DisplayClass34_0:<PostConfig>b__0(AsyncOperation) (at C:\gamedev\davaa\Davaa\Library\PackageCache\com.unity.remote-config@1.3.2-preview.2\Runtime\ConfigManager.cs:252)
    8. I/Unity   ( 7043): UnityEngine.AsyncOperation:InvokeCompletionEvent() (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/AsyncOperation.cs:21)
    9. I/Unity   ( 7043):
    10. I/Unity   ( 7043): (Filename: C Line: 0)
    11. I/Unity   ( 7043):
    12. I/Unity   ( 7043): backend IP:
    13. I/Unity   ( 7043): UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    14. I/Unity   ( 7043): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    15. I/Unity   ( 7043): UnityEngine.Logger:Log(LogType, Object)
    16. I/Unity   ( 7043): UnityEngine.Debug:Log(Object)
    17. I/Unity   ( 7043): Davaa.Providers.<>c:<SelectTestGroup>b__0_0(ConfigResponse) (at C:\gamedev\davaa\Davaa\Assets\Scripts\Providers\RemoteConfigProvider.cs:21)
    18. I/Unity   ( 7043): Unity.RemoteConfig.<>c__DisplayClass34_0:<PostConfig>b__0(AsyncOperation) (at C:\gamedev\davaa\Davaa\Library\PackageCache\com.unity.remote-config@1.3.2-preview.2\Runtime\ConfigManager.cs:252)
    19. I/Unity   ( 7043): UnityEngine.AsyncOperation:InvokeCompletionEvent() (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/AsyncOperation.cs:21)
    20.  
    as you can see, the log line 12 shows that the retrieved IP is empty. This is the result I got on version 2.0.0, 1.4.0 and 1.3.2-preview2
     
  19. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Forgot to mention, one of my coleagues found this one.
    For those who also use Proguard / other obfuscation tools and encountered issues with platform detection:

    Make sure to exclude properties / classes you're using for rules / determining platforms.

    Otherwise Remote Config will not detect platform correctly.
     
  20. creepteks

    creepteks

    Joined:
    Jun 2, 2017
    Posts:
    19
    Would you please elaborate more on excluding properties / classes used for rules / determining platforms?
     
  21. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    I was referring to my previous post:
    https://forum.unity.com/threads/remote-config-platforms.808791/#post-6357645

    My coleague ended up plain disabling Proguard as it yields 0 benefits whatsoever, and after that - Remote Config worked like a charm.

    -dontobfuscate should work as well (for the Proguard), in theory.

    If you still want to use it, or any other tool that modifies compiled end result code - referr to that tools manual.

    In short - you'd want to preserve "appAttribute" / "userAttribute" classes / or structs names same as they are in editor / defined on the remote. Otherwise they will not be compared correctly to the values received from the remote.
     
    Last edited: Nov 25, 2020
  22. creepteks

    creepteks

    Joined:
    Jun 2, 2017
    Posts:
    19
    But the thing is I'm not using Proguard or other code obfuscation tools. I get the same result with IL2CPP or Mono backend. I added the "app.platform" because the code was not working in the first place.After I added your suggestion, I didn't see any improvements
     
  23. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Try defining appAttributes with a lowercase. Maybe its case sensitive.
    Other than that - idk.

    Alternatively, use my method above with v1.4.0p1. It should work 100%.
    Here's how my rule looks (just in case):
    upload_2020-11-25_19-38-32.png
     
    Last edited: Nov 25, 2020
    creepteks likes this.
  24. creepteks

    creepteks

    Joined:
    Jun 2, 2017
    Posts:
    19
    starting the name of the struct with lowercase, as you guessed, now allows me to pass my specific user attributes (besides setting userCustomId) and app attributes when fetching the remote config. But, yet, it is not working on Android. I am using your method with no luck whatsoever. I am on v1.4.0-preview1.
     
  25. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Then it means something else is involved.

    Check your default environment, rules setup and which rules are enabled.

    Check if your rules are correct via dashboard (maybe something went wrong syncing?)
    (via https://app.remote-config.unity3d.com/ or https://dashboard.unity3d.com/remote-config)
     
  26. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    same issue. Unity 2019.4, RemoteConfig 2.0.1
    unity.platform == "iOS" - works
    unity.platform == "Android" - doesn't work
     
  27. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will check