简体   繁体   English

无法从Android应用程序中的Microsoft Intune获取应用程序配置策略

[英]Not able to fetch App Configurations Policy from Microsoft Intune in android app

The requirement is to create a key-value pair and add to the app configuration policy at portal side. 要求是创建一个键值对,并将其添加到门户网站侧的应用程序配置策略中。 ex. 例如 endpointURL : "some-value" endpointURL:“某些值”

The Android app should be configured in a way that it should access this configurations in the app and should be able to set the endpointURL in app. Android应用的配置方式应使其可以在应用中访问此配置,并且应能够在应用中设置endpointURL。

I followed below steps at this link to Support App configuration policies in the app : 在此链接中按照以下步骤操作,指向该应用程序中的“支持应用程序”配置策略:

Added the permissions to AndroidManifest.xml: 向AndroidManifest.xml添加了权限:

 <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> 

I have pasted below code inside LoginServiceImpl.java where I am setting endpoint URL. 我在设置端点URL的LoginServiceImpl.java中粘贴了以下代码。

MAMAppConfigManager configManager = MAMComponents.get(MAMAppConfigManager.class);
        String identity = "<user-name>@mobileinfy.onmicrosoft.com";
//       
        MAMAppConfig appConfig = configManager.getAppConfig(identity);  //<= this line returning null.
        Log.i("App Config Data = ",(appConfig == null ? "null" : appConfig.getFullData().toString()));
        String valueToUse = null;
        if (appConfig.hasConflict("endpointURL")) // <=So getting Exception at this line NullPointerException
         {
            List<String> values = appConfig.getAllStringsForKey("ServerUrl");
            for (String value : values) {

                    valueToUse = value;

            }
        } else {
            valueToUse = appConfig.getStringForKey("endpointURL ", MAMAppConfig.StringQueryType.Any);
        }
        Log.i("Found value " , valueToUse);

I followed the steps at this link to add app configuration policies in Intune portal 我按照此链接上的步骤在Intune门户中添加应用程序配置策略

Steps that I followed to test app : 1.Installed company portal and logged in using our Intune account id:@mobileinfy.onmicrosoft.com 2. Installed app using android studio 3. Tried to log in -> app crashed. 我测试应用程序的步骤如下:1.安装公司门户并使用我们的Intune帐户ID:@ mobileinfy.onmicrosoft.com登录2.使用android studio安装应用程序3.尝试登录->应用程序崩溃。 (as exception occurred.) (发生异常)。

Another set of steps to test app : 1. Generated apk -> uploaded to intune portal 2. Installed company portal and logged in using our Intune account id: ayush14197@mobileinfy.onmicrosoft.com 3. Assigned app config policies to this app and synced. 测试应用程序的另一组步骤: 1.生成apk->上载到intune门户2.安装公司门户并使用我们的Intune帐户ID:ayush14197@mobileinfy.onmicrosoft.com登录3.将应用程序配置策略分配给此应用程序并进行同步。 4. Tried installing app from company portal app. 4.尝试从公司门户应用程序安装应用程序。 5. Tried to log in -> app crashed. 5.尝试登录->应用程序崩溃。 (as exception occurred.) (发生异常)。

Could you please help me to get this issue resolved? 您能帮我解决这个问题吗? Thanks in advance. 提前致谢。

I think you're hitting two issues that aren't well documented in the Intune APP SDK docs: 我认为您遇到了两个Intune APP SDK文档中未充分记录的问题:

  1. MAMAppConfigManager.getAppConfig can return null if no app config data has been receieved for the user. 如果尚未为用户收到任何应用程序配置数据,则MAMAppConfigManager.getAppConfig可以返回null。 The example given should be performing a null check on appConfig . 给出的示例应在appConfig上执行空检查。
  2. To receive app config, the user must have MAM policy targeted for at least one app for app config to be delivered. 要接收应用程序配置,用户必须具有针对至少一个应用程序的MAM策略,才能交付应用程序配置。 This is mentioned, but only on the Managed Browser app config page even though it applies to all apps. 提及了此内容,但仅在“ 受管浏览器”应用程序配置页面上提及,即使它适用于所有应用程序。

I hope that helps -- these documentation issues should be fixed in the next release of the SDK. 希望对您有所帮助-这些文档问题应在下一版SDK中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM