跳过内容

开始使用

  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 });

targetLanguage

常见流程

交互式登录和注册

交互式登录和注册
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): 使用 Intune 注册 MSAL 帐户并触发注册。
  • loginAndEnrollAccount(): 让 Intune 驱动登录和注册流程。
  • appConfig(user): 读取 Intune 应用程序配置值。
  • getPolicy(user): 读取 Intune 应用程序保护策略。
  • groupName(user): 读取公共配置助手值(当存在时)。 GroupName : 检查捆绑的 Intune 和 MSAL 版本。
  • sdkVersion(): 使用 Microsoft 登录并返回令牌和帐户元数据。

平台说明

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