跳过内容

开始使用

GitHub
  1. 安装包

    终端窗口
    bun add @capgo/capacitor-intune
  2. 同步本地项目

    终端窗口
    bunx cap sync
  3. 完成本机 Intune 设置 按照专门的 iOS 设置Android 设置 页面进行。 Intune 还需要主机应用本机配置来支持代理认证、重定向 URI、清单、特权和 MSAL 配置。

  • Capacitor 8+
  • Android 与 Intune Android SDK 12.0.3
  • iOS 与 Intune iOS SDK 21.5.1
  • iOS 部署目标 17.0+

Ionic的Intune文档目前将2026年1月19日设为截止日期,要求使用Xcode 26构建的应用程序,需要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' });
  • acquireToken(options):开始 Microsoft 登录并返回令牌及账户元数据。
  • acquireTokenSilent(options):读取缓存令牌以获取现有账户。
  • registerAndEnrollAccount(options):将 MSAL 账户注册到 Intune 并触发注册。
  • loginAndEnrollAccount(): 让 Intune 驱动登录和注册流程。
  • appConfig(user): 读取 Intune 应用程序配置值以获取帐户。
  • getPolicy(user): 读取当前 Intune 应用程序保护策略以获取帐户。
  • groupName(user): 读取公共 GroupName config helper 值,当存在时。
  • sdkVersion(): 检查打包的 Intune 和 MSAL 版本。

: 平台说明

: 平台说明部分
  • : 不支持 Web。
  • : iOS 和 Android 都需要本机项目配置,超出了 cap sync.
  • : 您的 Azure 注册、Intune 策略分配、重定向 URI 和权限仍然是应用程序特有的。

: 从 Getting Started 继续进行

继续从 Getting Started 中开始

如果您正在使用 Getting Started 来规划迁移和企业运营,连接它与 使用 @capgo/capacitor-intune 为在使用 @capgo/capacitor-intune 中的本机功能 Capgo 企业 为在 Capgo 企业 中的产品工作流 Ionic 企业插件替代品 为在 Ionic 企业插件替代品 中的产品工作流 Capgo 替代品 为在 Capgo 替代品 中的产品工作流 Capgo 咨询 为产品工作流程在 Capgo 咨询中