Microsoft Intune App SDK Cordova 外掛程式Microsoft Intune App SDK Cordova Plugin


Intune 將於 2018 年 5 月 1 日結束對 Microsoft Intune App SDK Cordova 外掛程式的支援。Intune is ending support for the Microsoft Intune App SDK Cordova Plugin on May 1, 2018. 我們建議您改用 Intune App Wrapping Tool。We recommend that you use the Intune App Wrapping Tool instead. 如需了解 App Wrapping Tool 的詳細資訊,請參閱適用於 iOS 的 App Wrapping Tool適用於 Android 的 App Wrapping ToolFor more information about the App Wrapping Tool, see App Wrapping Tool for iOS and App Wrapping Tool for Android. 如需這項變更的詳細資訊,請參閱 Microsoft Intune 的新功能通知區段。For more information about this change, see the Notices section of What's new in Microsoft Intune.


Intune App SDK Cordova 外掛程式能在使用 Cordova 建置的 iOS 和 Android 應用程式中啟用 Intune 行動應用程式保護原則。The Intune App SDK Cordova Plugin in iOS and Android apps built with Cordova. 外掛程式可讓開發人員將 Intune 應用程式和資料保護功能整合至其 Cordova 應用程式。The plugin allows developers to integrate Intune app and data protection features into their Cordova-based app.


您可能想要先閱讀 Intune App SDK 快速入門文章,其中說明如何在每個支援的平台上進行整合準備。You may wish to first read the Get Started with Intune App SDK article, which explains how to prepare for integration on each supported platform.

您會發現您可以啟用 SDK 功能,而不需要變更您應用程式的行為。You will find that you can enable SDK features without changing your app's behavior. 當您於 iOS 或 Android 應用程式中建置該外掛程式之後,Microsoft Intune 系統管理員將能部署 Intune 應用程式保護原則,其中包含各種不同的資料保護功能。Once you have built the plugin into your iOS or Android app, the Microsoft Intune administrator will be able to deploy Intune app protection policy, which consists of a variety of data protection features. 該外掛程式已建置為能使大部分的步驟在 Cordova 建置程序中自動執行。The plugin is built so that most of the steps are automatically performed in the Cordova build process. 如此一來,您應該能夠快速地啟用應用程式的 Intune 應用程式保護。As a result, you should be able to get your app enabled for Intune app protection quickly. 若要開始,請根據目標平台遵循下列步驟。To get started, follow the steps below based on your target platform.

支援的平台Supported Platforms

  • 外掛程式適用於 Windows、Mac 和 Linux OSThe plugin works on Windows, Mac and Linux OS
  • 外掛程式適用於 minSdkVersion >= 14 且 targetSdkVersion <= 24 的 Android 應用程式The plugin works for Android apps with minSdkVersion >= 14 and targetSdkVersion <= 24
  • 外掛程式適用於以 iOS 9.0 或以上版本為目標的 iOS 應用程式。The plugin works for iOS apps targeted for iOS 9.0 and above.

Intune 行動應用程式管理案例Intune Mobile Application Management scenarios

  • Intune MDM 已註冊的裝置Intune MDM-enrolled devices
  • 協力廠商 EMM 已註冊的裝置Third-party EMM-enrolled devices
  • 未受管理的裝置 (未使用任何 MDM 註冊)Unmanaged devices (not enrolled with any MDM)

使用 Intune App SDK Cordova 外掛程式建置的 Cordova 應用程式,現在可以在 Intune 行動裝置管理 (MDM) 註冊裝置和未註冊裝置上,接收 Intune 應用程式保護原則。Cordova apps built with the Intune App SDK Cordova Plugin can now receive Intune app protection policies on both Intune mobile device management (MDM) enrolled devices and unenrolled devices.



  • 最新的 Microsoft Intune 公司入口網站應用程式一律必須安裝在裝置上。The latest Microsoft Intune Company Portal app must always be installed on the device.
  • 使用外掛程式時,Java 7 至少必須在將執行 Cordova 組建的路徑上。Java 7 at minimum must be on the path where you will execute Cordova build when using the plugin.


  • 最新的 Microsoft Intune 公司入口網站應用程式必須安裝在裝置上,以取得 MDM 功能。The latest Microsoft Intune Company Portal app must be installed on the device for MDM features. 這對於無裝置註冊功能的 Intune 應用程式保護原則「並非」必要。It is not needed for Intune app protection policy without device enrollment features.

針對兩個平台Both platforms


由於這裡 (英文) 所記載的 Apache Cordova Bug,已經有外掛程式相依性的應用程式將不會把外掛程式自動升級為要求的版本。Due to an Apache Cordova bug the filed here, apps that already have the plugin dependency will not automatically upgrade the plugin to the requested version.


  1. 更新您的 ADAL 版本︰Update your version of ADAL:

    cordova plugin remove cordova-plugin-ms-adal
    cordova plugin add cordova-plugin-ms-adal@0.8.x
  2. 新增 Intune App SDK for Cordova 外掛程式:Add the Intune App SDK for Cordova plugin:

    cordova plugin add cordova-plugin-ms-intune-mam

將外掛程式建置到 iOS 應用程式中Build the plugin into your iOS app

您必須完成一些步驟,您的應用程式才能針對 Intune 應用程式保護原則進行啟用。You'll need to complete some steps for your app to be enabled for Intune app protection policy. 為了方便起見,這些步驟會在 Cordova 建置流程中自動執行,以作為建置前攔截程序。For convenience, these steps are performed automatically in the Cordova build process as a pre-build hook. 如此一來,自動化的步驟會修改您的 *.pbxproj*-Info.plist*.entitlements 等專案組態相關聯檔案。As a result, the automated steps will modify your *.pbxproj , *-Info.plist, and *.entitlements files that are associated with a project configuration. 如果您的專案未包含的 entitlements 檔案,則外掛程式會自動建立一個。If your project doesn't contain an entitlements file, the plugin will create one automatically.

這項設定只支援單一目標,而且將會在有多個目標時於第一個發現的目標上執行設定。This setup only supports a single target and will perform the configuration on the first target found if there are multiple targets. 如果此程序失敗,請確認︰If the process fails, check that:

  1. 您的應用程式的 Xcode 專案是 [name].xcodeproj,其中 [name]config.xml 中已定義的值Your app's Xcode project is [name].xcodeproj where [name] is the value defined in config.xml
  2. 您的專案使用標準 Cordova 應用程式目錄結構Your project uses the standard Cordova app directory structure.

將外掛程式建置到 Android 應用程式中Build the plugin into your Android app

  1. 使用最新的 Cordova 工具匯入此外掛程式。Import this plugin with the latest Cordova tools. 外掛程式會自動叫用作為 after_compile 步驟。The plugin will be automatically invoked as an after_compile step.

  2. 外掛程式會在建置程序的結尾建立建置 APK (Android API 14+) 的啟用 Intune 版本。The plugin will create a Intune-enabled version of a built apk (Android API 14+) at the end of the build process. 建置輸出將會包含 [Project]-intunewrapped-[Build_Configuration].apk (例如 helloWorld-intunewrapped-debug.apk)。The build output will contain a [Project]-intunewrapped-[Build_Configuration].apk (e.g. helloWorld-intunewrapped-debug.apk).


外掛程式只支援 gradle 組建。The plugin only supports gradle builds.

由於這裡記載的 Cordova bug,它導致會在 cordova run 忽略特定 Cordova 攔截程序。若要從命令列執行包裝的應用程式,您必須執行下列各項︰Due to a Cordova bug filed here that causes certain Cordova hooks to be ignored on cordova run, to run the wrapped app from the command line, you must do the following:

$ cordova build
$ cordova run --nobuild

登入 Android 應用程式Sign your Android app

外掛程式會於下列位置自動識別您提供給 Cordova 的簽署資訊:The plugin automatically recognizes signing information you have provided to Cordova at the following locations:

  • platforms/android/debug-signing.propertiesplatforms/android/
  • platforms/android/release-signing.propertiesplatforms/android/
  • res/native/android/ant.propertiesres/native/android/

請參閱 Cordova gradle 簽署資訊 (英文) 以取得預期格式的詳細資訊。See the Cordova gradle signing information for more information about the expected format.

我們目前不支援以 build.json 或透過參數提供的任意位置來為 Cordova 組建提供簽署資訊的能力。We currently don't support the ability to provide signing information in build.json or arbitrary locations provided via parameters to Cordova build.

從 Visual Studio 偵錯Debugging from Visual Studio

在第一次啟動應用程式之後,您應該會看到一個對話方塊,通知您應用程式由 Intune 管理。After launching the app for the first time you should see a dialog notifying you that the app is managed by Intune. 按一下 [不要再顯示],然後再從 VS 按一下 [偵錯/執行] 按鈕,以命中中斷點。Hit "Don't show again" and click the debug/run button again from VS for breakpoints to be hit.

已知限制Known Limitations


  • MultiDex 支援不完整。MultiDex support is incomplete.
  • 應用程式的 minSdkVersion 必須為 14,且 targetSdkVersion 必須為 24 或以下。App must have minSdkVersion of 14 and targetSdkVersion of 24 or below. 我們目前不支援以 API 25 為目標的應用程式We currently don't support apps targeting API 25
  • 我們無法重新簽署已使用 V2 簽署配置進行簽署的應用程式。We cannot re-sign apps that were signed with the V2 Signature Scheme. 當 V2 簽署的應用程式由外掛程式包裝時,包裝的輸出 .apk 將會移除簽署。When V2-signed apps are wrapped by the plugin, the wrapped output .apk will be unsigned. *

    • 您可以將下列內容新增至 build-extras.gradle 檔案,來停用 Cordova 的預設 V2 簽署:You can disable Cordova's default V2 Signing by adding the following to your build-extras.gradle file:
    android {
        signingConfigs {
            release {
                v2SigningEnabled false
            debug {
                v2SigningEnabled false
        buildTypes {
            release {
                signingConfig signingConfigs.release
            debug {
                signingConfig signingConfigs.debug


  • 每當您在 Info.plist 檔案的 CFBundleDocumentTypes 節點下修改 UTI 清單,都必須在相同 plist 檔案的 [已匯入 UTI] 區段 (UTImportedTypeDeclarations 節點) 清除 Intune UTI,然後才再次建置。Whenever you modify the list of UTI's under the CFBundleDocumentTypes node of the Info.plist file, you must clear the Intune UTI's in the Imported UTI's section of the same plist file (UTImportedTypeDeclarations node) before building again. 所有的 Intune UTI 都會以 前置詞做為開頭。All of the Intune UTI's will start with the prefix

  • 如果您想要從 Cordova 專案移除適用於 Cordova 的 Intune App SDK 外掛程式,則也必須移除 iOS 平台,並且重新新增它,以復原 .xcodeproj 和.plist 檔案中的一些 Intune 設定。If you want to remove the Intune App SDK for Cordova plugin from your Cordova project, you must also remove the iOS platform and re-add it, in order to undo some of the Intune configuration in the .xcodeproj and .plist files.