Getting Started
复制包含安装步骤和本插件全markdown指南的设置提示。
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技能添加到您的AI工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
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 还需要主机应用的本机配置来支持授权代理、重定向 URI、清单、特权和 MSAL 配置。
- Capacitor 8+
- Android with Intune Android SDK
12.0.3 - iOS with 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,});静默令牌刷新
静默令牌刷新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 登录并返回令牌及帐户元数据acquireTokenSilent(options): 读取缓存令牌以获取现有帐户registerAndEnrollAccount(options): 将 MSAL 帐户注册到 Intune 并触发注册loginAndEnrollAccount(): 让 Intune 驱动登录和注册流程appConfig(user): 读取 Intune 应用程序配置值以获取帐户getPolicy(user): 读取当前 Intune 应用保护策略。groupName(user): 当存在时读取公共GroupNameconfig 助手值。sdkVersion(): 检查打包的 Intune 和 MSAL 版本。
平台注意事项
标题为“平台注意事项”的部分。- Web 不受支持。
- iOS 和 Android 都需要本机项目配置,超出
cap sync. - 您的 Azure 注册、Intune 策略分配、重定向 URI 和权限仍然是应用特有的。
继续从 Getting Started
标题为“继续从 Getting Started”的部分。如果您正在使用 开始使用 用于规划迁移和企业运营,连接它 使用@capgo/capacitor-intune 用于@capgo/capacitor-intune的本地能力 Capgo企业 用于Capgo企业的产品工作流程 Ionic企业插件替代品 用于Ionic企业插件替代品的产品工作流程 Capgo替代品 用于Capgo替代品的产品工作流程 Capgo咨询 用于Capgo咨询的产品工作流程