跳过内容

安卓设置

1. 在 Intune Gradle 插件中添加

标题为“1. 在 Intune Gradle 插件中添加”

在您的应用项目的顶级 android/build.gradle添加 Intune Gradle 插件 JAR 到 buildscript classpath。该插件包包括:

  • android/ms-intune-app-sdk-android/GradlePlugin/com.microsoft.intune.mam.build.jar

还包括 Ionic 文档中用于当前 Intune Android SDK 版本的 Duo Maven feed:

maven {
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
name 'Duo-SDK-Feed'
}

2. 更新应用模块

标题:2. 更新应用模块

android/app/build.gradle:

apply plugin: 'com.microsoft.intune.mam'

并且保持资源优化禁用:

android.enableResourceOptimizations=false

3. 提供 auth_config.json

标题:3. 提供 auth_config.json

创建 android/app/src/main/res/raw/auth_config.json:

{
"client_id": "YOUR_CLIENT_ID",
"authorization_user_agent": "BROWSER",
"redirect_uri": "msauth://YOUR_PACKAGE/YOUR_SIGNATURE_HASH",
"broker_redirect_uri_registered": true,
"account_mode": "MULTIPLE",
"authorities": [
{
"type": "AAD",
"audience": {
"type": "AzureADMyOrg"
}
}
]
}

标题:3. 提供 auth_config.json

4. 配置应用 <application> 标签

标题:4. 配置应用

如果您的应用程序尚未定义自定义 Application,设置:

<application
android:name="app.capgo.intune.IntuneApplication"
android:enableOnBackInvokedCallback="false">

如果您已经有一个自定义 Application,扩展 MAMApplication 并注册 IntuneMamServiceAuthenticationCallbackonMAMCreate().

5. 添加代理认证查询和重定向处理

标题:5. 添加代理认证查询和重定向处理

在 Ionic 文档中添加包可见性查询:

  • com.azure.authenticator
  • com.microsoft.windowsintune.companyportal
  • 浏览器检测意图

另外添加 BrowserTabActivity 与您的 msauth:// 重定向 URI 主机/路径,以便 MSAL 可以完成登录回旋镖。

一旦应用级本机设置完成,Capacitor API 与 iOS 一样:

import { IntuneMAM } from '@capgo/capacitor-intune';
const auth = await IntuneMAM.acquireToken({
scopes: ['https://graph.microsoft.com/.default'],
});
await IntuneMAM.registerAndEnrollAccount({
accountId: auth.accountId,
});