快速入门
复制包含安装步骤和该插件完整 Markdown 指南的配置 prompt。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-intune`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/intune/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
你可以使用我们的 AI 辅助设置来安装插件。使用以下命令将 Capgo skills 添加到你的 AI 工具中:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下 prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-intune` plugin in my project.如果你更想手动设置,请运行以下命令安装插件,并按照下方各平台的说明操作:
-
安装软件包
终端窗口 bun add @capgo/capacitor-intune -
同步原生项目
终端窗口 bunx cap sync -
完成 Intune 原生配置 请参阅专门的 iOS 配置 以及 Android 配置 页面。Intune 仍需在宿主应用中进行原生配置,包括 brokered auth、重定向 URI、manifests、entitlements 和 MSAL 配置。
快速入门
章节标题为“快速入门”import { IntuneMAM } from '@capgo/capacitor-intune';
const result = await IntuneMAM.acquireToken({ scopes: ['openid'] });// The result holds sensitive values: use it without logging it.示例:acquireTokenSilent
“示例:acquireTokenSilent”章节import { IntuneMAM } from '@capgo/capacitor-intune';
const result = await IntuneMAM.acquireTokenSilent({ scopes: ['openid'], accountId: 'acquireToken',});// The result holds sensitive values: use it without logging it.示例:registerAndEnrollAccount
“示例:registerAndEnrollAccount”章节import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.registerAndEnrollAccount({ accountId: 'account-id-123' });常见坑点
章节标题为“常见陷阱”- 监听器: 在页面卸载时移除句柄。
- 原生同步:运行
bunx cap sync在插件升级后。 - 唯一可信来源:信任
src/definitions.ts在 GitHub 仓库中。
- Capacitor 8+
- 使用 Intune 的 Android 版 SDK
12.0.3 - 使用 Intune 的 iOS 版 SDK
21.5.1 - iOS 部署目标
17.0+
Ionic 的 Intune 文档目前指出,使用 Xcode 26 构建的应用需在 2026 年 1 月 19 日前完成,并要求使用 Intune iOS SDK 21.1.0+. 该插件已使用 21.5.1.
基础用法
标题为“基础用法”的章节import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.addListener('appConfigChange', (result) => { console.log('App config changed', result.accountId);});
await IntuneMAM.addListener('policyChange', (result) => { console.log('Policy changed', result.accountId);});
const auth = await IntuneMAM.acquireToken({ scopes: ['https://graph.microsoft.com/.default'], loginHint: 'alex@example.com',});
await IntuneMAM.registerAndEnrollAccount({ accountId: auth.accountId,});
const appConfig = await IntuneMAM.appConfig({ accountId: auth.accountId,});
const policy = await IntuneMAM.getPolicy({ accountId: auth.accountId,});
console.log({ auth, appConfig, policy });const auth = await IntuneMAM.acquireToken({ scopes: ['https://graph.microsoft.com/.default'],});
await IntuneMAM.registerAndEnrollAccount({ accountId: auth.accountId,});静默 Token 刷新
标题为 “Silent token refresh” 的章节const token = await IntuneMAM.acquireTokenSilent({ accountId: 'AAD_OBJECT_ID', scopes: ['https://graph.microsoft.com/.default'], forceRefresh: true,});读取当前已注册的账号
“读取当前已注册账号”章节const user = await IntuneMAM.enrolledAccount();退出登录或选择性擦除数据
“退出登录或选择性擦除”章节await IntuneMAM.logoutOfAccount({ accountId: 'AAD_OBJECT_ID' });await IntuneMAM.deRegisterAndUnenrollAccount({ accountId: 'AAD_OBJECT_ID' });API 概览
“API 概览”章节acquireToken(options): 开始 Microsoft 登录并返回 token 及账号元数据。acquireTokenSilent(options): 读取现有账号的缓存 token。registerAndEnrollAccount(options): 将 MSAL 账号注册至 Intune 并触发注册流程。loginAndEnrollAccount(): 由 Intune 主导登录和注册流程。appConfig(user): 读取该账户的 Intune 应用配置值。getPolicy(user): 读取该账户当前的 Intune 应用保护策略。groupName(user): 读取通用的GroupName配置助手值(如果存在)。sdkVersion(): 检查打包的 Intune 和 MSAL 版本。
平台注意事项
“平台说明”章节- 不支持 Web 端。
- iOS 和 Android 都需要在原生项目中进行配置,超出
cap sync. - 您的 Azure 注册、Intune 策略分配、重定向 URI 和权限仍属于应用特定配置。
从入门指南继续
“从入门指南继续”章节如果你正在使用 快速入门 要规划迁移和企业运营,请将其与 使用 @capgo/capacitor-intune 用于“使用 @capgo/capacitor-intune”中的原生能力, Capgo 企业版 用于 Capgo Enterprise 中的产品工作流, Ionic Enterprise 插件替代方案 用于 Ionic Enterprise 插件替代方案的产品工作流, Capgo 替代方案 适用于 Capgo Alternatives 的产品工作流,以及 Capgo 咨询 适用于 Capgo Consulting 的产品工作流。