安卓设置
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示。
1. 在 Intune Gradle 插件中添加
Section titled “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. 更新应用程序模块
Section titled “2. 更新应用程序模块”在 android/app/build.gradle:
apply plugin: 'com.microsoft.intune.mam'并保持资源优化禁用:
android.enableResourceOptimizations=false3. 提供 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> 标签
如果您的应用程序尚未定义自定义,请设置: Application复制到剪贴板
<application android:name="app.capgo.intune.IntuneApplication" android:enableOnBackInvokedCallback="false">如果您已经有一个自定义 Application,扩展 MAMApplication 并注册 IntuneMamServiceAuthenticationCallback 在 onMAMCreate().
5. 添加代理认证查询和重定向处理
标题为“5. 添加代理认证查询和重定向处理”添加包可见性查询 Ionic 文档:
com.azure.authenticatorcom.microsoft.windowsintune.companyportal- 浏览器检测意图
另外添加 BrowserTabActivity 与您的 msauth:// 重定向 URI 主机/路径以便 MSAL 可以完成登录环回
6. 使用插件
第 6 章:使用插件应用级本地设置完成后,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,});