有些專為企業設計的應用程式有內建的設定 (稱為「受管理的設定」),IT 管理員可以從遠端進行設定。例如,應用程式可能只在裝置連上 Wi-Fi 時同步處理資料。所有解決方案集都要求 IT 管理員能夠指定受管理的設定並套用至裝置。
下圖以 Google Play EMM API 提供的選項總覽,說明受管理設定管理的幾個主要階段。
確認應用程式是否支援受管理的設定
使用 Products.getAppRestrictionsSchema
來判斷應用程式是否支援受管理設定。以下為使用 Java 專用 Google Play EMM API 用戶端程式庫的範例。
public AppRestrictionsSchema getAppRestrictionsSchema(String enterpriseId,
String productId, String language) throws IOException {
return androidEnterprise
.product()
.getAppRestrictionsSchema(enterpriseId, productId, language)
.execute();
}
所有應用程式都會傳回應用程式限制 (受管理設定) 結構定義。如果呼叫傳回空白結構定義,表示應用程式不支援管理設定。如果呼叫傳回包含一組限制的結構定義,則應用程式支援受管理的設定。舉例來說,如果應用程式具有透過 VPN 進行遠端列印的屬性,則可能會將以下回應傳回 Products.getAppRestrictionsSchema
。
{
"kind": "androidenterprise#appRestrictionsSchema",
"restrictions": [
{
"key": "printing_enabled",
"title": "Enable printing",
"restrictionType": "bool",
"description": "Allow user to print from the app",
"defaultValue": {
"type": "bool",
"valueBool": true,
}
},
{
"key": "vpn_configurations",
"title": "VPN configurations",
"restrictionType": "bundle_array",
"description": "List of VPN configurations",
"nestedRestriction": [
{
"key": "vpn_configuration",
"title": "VPN configuration",
"restrictionType": "bundle",
"nestedRestrictions": [
{
"key": "server",
"title": "VPN server host",
"restrictionType": "string"
},
{
"key": "username",
"title": "VPN account username",
"restrictionType": "string"
}
]
}
]
}
]
}
指定受管理的設定
如果應用程式支援受管理的設定,您可以嵌入受管理的設定 iframe,或開發自己的 UI,讓 IT 管理員透過 EMM 控制台進行設定。
方法 1:嵌入受管理的設定 iframe
如要支援代管設定,最簡單的方法就是將受管理的設定 iframe 嵌入 EMM 控制台。iframe 會擷取指定應用程式的受管理設定結構定義,讓 IT 管理員能夠儲存、編輯及刪除自訂設定設定檔。您可以使用 Play EMM API 將自訂設定檔套用至使用者的裝置。如要進一步瞭解 iframe,以及如何將 iframe 新增至主控台,請參閱受管理的設定 iframe。
方法 2:建立自己的 UI
您可以使用從 Products.getAppRestrictionsSchema
傳回的設定,建立自己的 UI,讓 IT 管理員能管理應用程式設定。
套用受管理的設定
如要將受管理的設定套用至裝置,DPC 必須與 DPC 支援資料庫整合,詳情請參閱建構裝置政策控制器。DPC 支援資料庫會以公開透明的方式處理委派給 Google Play 以套用受管理設定。
您可以在 Device
的 policy
中設定 policy.productPolicy.managedConfiguration
,將受管理的設定套用至裝置。
使用 mcmId
每次 IT 管理員從受管理的設定 iframe 儲存新的設定設定檔時,iframe 都會傳回名為 mcmId
的專屬 ID。mcmId
沒有限制可套用的裝置數量,且沒有到期時間。
如要為裝置套用組態設定檔,請在 Device
的 policy
中設定 policy.productPolicy.managedConfiguration.configurationVariables.mcmId
。
如要允許 IT 管理員在受管理的設定 iframe 中使用變數 (例如 $FirstName、$LastName),必須使用 policy.productPolicy[].managedConfiguration.configurationVariables.mcmId.variableSet[]
定義設定檔中包含的任何變數。
使用代管資源清單
您也可以在 Device
的 policy
中設定 policy.productPolicy.managedConfiguration.managedProperty[]
,加入一組代管屬性。
以下範例說明如何定義設定。這項設定包含 bundle_array
(清單),內含兩個軟體包屬性 (在本例中為相關的屬性群組,是指 VPN 的屬性群組)。
ManagedConfiguration managedConfiguration = new ManagedConfiguration()
.setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("printing_enabled")
.setValueBool(true),
new ManagedProperty()
.setKey("vpn_configurations")
.setValueBundleArray(
ImmutableList.of(
new ManagedPropertyBundle().setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("server")
.setValueString("vpn1.example.com"),
new ManagedProperty()
.setKey("username")
.setValueString("john.doe"))),
new ManagedPropertyBundle().setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("server")
.setValueString("vpn2.example.com"),
new ManagedProperty()
.setKey("username")
.setValueString("jane.doe")))))));
如要進一步瞭解應用程式可支援的不同設定屬性,請參閱「定義受管理的設定」。
列出應用程式的組態設定檔
視解決方案設計方式而定,您可能需要顯示應用程式的已儲存設定設定檔清單。如要擷取這份清單,請呼叫 Managedconfigurationssettings.list
。