跳过内容

安卓设置

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 源:

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"
}
}
]
}

插件在运行时期期望在MSAL和Intune认证回调中存在此文件。

4. 配置<application>标签 <application> 标签

标题为“4. 配置<application>标签”

如果您的应用程序尚未定义自定义 Application复制到剪贴板

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

扩展 Application并注册 MAMApplicationIntuneMamServiceAuthenticationCallback 5. 添加代理身份验证查询和重定向处理 onMAMCreate().

5. 添加代理身份验证查询和重定向处理

Section titled “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,
});