@capgo/capacitor-intune
v9.0.0
Published
Capacitor plugin for Microsoft Intune MAM enrollment, app protection policies, app config, and MSAL authentication.
Readme
@capgo/capacitor-intune
Make your Capacitor app manageable with Microsoft Intune: enroll accounts, apply app protection policies, read app config and sign in with MSAL. Ship to enterprises that require Intune MAM.
🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use
@capgo/capacitor-intunein your Capacitor app:npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-intune to my Capacitor app and wire it up." Agent setup guides · Hosted MCP
Built and maintained with AI
We build, improve and fix our plugins with heavy use of AI, so issues usually get fixed in under a day and pull requests get feedback the same day. A human still reviews, tests and merges 50+ pull requests daily.
- Most plugin issues get a fix pull request the same day, often within a couple of hours, and are usually resolved in one to two days.
- Every pull request goes through our AI review system, usually within minutes.
- Our AI pre-checks tests, code review, conventions and security, then a human reviews, tests and merges.
- A human, Martin, reviews, tests and merges 50+ pull requests every day.
- In the last 90 days, 95% of plugin issues were resolved.
Learn more about how we build with AI
Key features
- MSAL sign-in:
acquireToken()andacquireTokenSilent()return Microsoft access tokens. - Enrollment:
registerAndEnrollAccount(),loginAndEnrollAccount(),enrolledAccount()anddeRegisterAndUnenrollAccount(). - App config and policy:
appConfig(),getPolicy()andgroupName(), withappConfigChangeandpolicyChangeevents. - Diagnostics:
sdkVersion()anddisplayDiagnosticConsole(). - Official SDKs: Intune App SDK and MSAL on iOS and Android.
- Platforms: iOS and Android. Not available on web.
What it covers
- Interactive and silent Microsoft sign-in with MSAL.
- Intune account registration, enrollment, logout, and selective wipe helpers.
- Native Intune app configuration and app protection policy access.
- Native change listeners for policy and app config refresh events.
- iOS and Android native Intune SDK integration from one Capacitor API.
Platform requirements
- Capacitor 9+
- Android with the Microsoft Intune Android SDK
12.0.3 - iOS with the Microsoft Intune iOS SDK
21.5.1 - iOS deployment target
17.0+
Ionic's Intune docs currently note that, starting January 19, 2026, apps built with Xcode 26 must use Intune iOS SDK 21.1.0 or later. This plugin bundles 21.5.1 for that reason.
Compatibility
| Plugin version | Capacitor compatibility | Maintained | | -------------- | ----------------------- | ---------- | | v9.*.* | v9.*.* | ✅ | | v8.*.* | v8.*.* | On demand |
Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (for example, plugin v9 for Capacitor 9).
Migrating from v8 to v9
v9 of @capgo/capacitor-intune targets Capacitor 9. Update Capacitor and this plugin together, then sync the native projects:
npm install @capacitor/core@^9.0.0 @capacitor/cli@^9.0.0 @capacitor/ios@^9.0.0 @capacitor/android@^9.0.0 @capgo/capacitor-intune@^9.0.0
npx cap syncCapacitor 9 needs Node.js 24+, iOS 16+ (Xcode 27) and Android minSdk 26 / compileSdk 37. Follow the official Capacitor 9 update guide for the app side changes.
No plugin API was removed: the JavaScript API of v9 is the same as v8.
Install
You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-intune` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
bun add @capgo/capacitor-intune
bunx cap syncNative setup
This plugin wraps the native Intune SDKs, but your app still needs the host-project configuration Microsoft and Ionic require.
Android
- Add the Intune Gradle plugin to your app project's
android/build.gradlebuildscript classpath. - Add the Duo Maven feed Ionic calls out for current Intune Android SDK builds.
- Apply
com.microsoft.intune.mamin your app module. - Add the Intune SDK AAR and keep
android.enableResourceOptimizations=false. - Add
android:name="app.capgo.intune.IntuneApplication"to your<application>tag if you do not already use a customApplication. - If you do use a custom
Application, extendMAMApplicationand registerIntuneMamServiceAuthenticationCallbackinonMAMCreate(). - Add broker/auth queries plus the
BrowserTabActivityintent filter for yourmsauth://redirect URI. - Create
android/app/src/main/res/raw/auth_config.jsonwith your MSAL app registration details.
Minimal auth_config.json example:
{
"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"
}
}
]
}If you target Android 16+, Ionic's docs also recommend android:enableOnBackInvokedCallback="false" on the <application> tag until the Intune SDK updates its back navigation support.
iOS
- Add your Intune and MSAL settings under
IntuneMAMSettingsinInfo.plist. - Configure your URL scheme / redirect URI for MSAL.
- Forward the auth callback URL to
MSALPublicClientApplication.handleMSALResponse(...)fromAppDelegate. - Run Microsoft's
IntuneMAMConfiguratoragainst your app'sInfo.plistand entitlements. - Keep the iOS deployment target at
17.0+.
Minimal Info.plist configuration:
<key>IntuneMAMSettings</key>
<dict>
<key>ADALClientId</key>
<string>YOUR_CLIENT_ID</string>
<key>ADALRedirectUri</key>
<string>msauth.com.example.app://auth</string>
<key>ADALAuthority</key>
<string>https://login.microsoftonline.com/common</string>
</dict>AppDelegate.swift example:
import MSAL
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return MSALPublicClientApplication.handleMSALResponse(
url,
sourceApplication: options[.sourceApplication] as? String
)
}Usage
import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.addListener('appConfigChange', (result) => {
console.log('Intune app config changed', result.accountId);
});
await IntuneMAM.addListener('policyChange', (result) => {
console.log('Intune policy changed', result.accountId);
});
const auth = await IntuneMAM.acquireToken({
scopes: ['https://graph.microsoft.com/.default'],
loginHint: '[email protected]',
});
await IntuneMAM.registerAndEnrollAccount({ accountId: auth.accountId });
const user = await IntuneMAM.enrolledAccount();
const appConfig = await IntuneMAM.appConfig({ accountId: auth.accountId });
const policy = await IntuneMAM.getPolicy({ accountId: auth.accountId });
const versions = await IntuneMAM.sdkVersion();
console.log({ user, appConfig, policy, versions });Notes
- Web is not supported; the web implementation throws an unavailable error.
- The plugin does not create your Azure app registration, Intune policies,
auth_config.json, or iOS entitlements for you. - For iOS, follow Microsoft's latest Intune MAM configurator and entitlement guidance in addition to the plugin setup above.
API
acquireToken(...)acquireTokenSilent(...)registerAndEnrollAccount(...)loginAndEnrollAccount()enrolledAccount()deRegisterAndUnenrollAccount(...)logoutOfAccount(...)appConfig(...)getPolicy(...)groupName(...)sdkVersion()displayDiagnosticConsole()addListener('appConfigChange', ...)addListener('policyChange', ...)removeAllListeners()- Interfaces
- Type Aliases
acquireToken(...)
acquireToken(options: AcquireTokenOptions) => Promise<IntuneMAMAcquireToken>Present the Microsoft sign-in flow and return an access token plus the account metadata.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| options | AcquireTokenOptions |
Returns: Promise<IntuneMAMAcquireToken>
acquireTokenSilent(...)
acquireTokenSilent(options: AcquireTokenSilentOptions) => Promise<IntuneMAMAcquireToken>Acquire a token from the MSAL cache for a previously signed-in user.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| options | AcquireTokenSilentOptions |
Returns: Promise<IntuneMAMAcquireToken>
registerAndEnrollAccount(...)
registerAndEnrollAccount(options: RegisterAndEnrollAccountOptions) => Promise<void>Register a previously authenticated account with Intune and start enrollment.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------- |
| options | RegisterAndEnrollAccountOptions |
loginAndEnrollAccount()
loginAndEnrollAccount() => Promise<void>Ask Intune to authenticate and enroll a user without first requesting an app token.
enrolledAccount()
enrolledAccount() => Promise<IntuneMAMUser | undefined>Return the currently enrolled Intune account, if one is available.
Returns: Promise<IntuneMAMUser>
deRegisterAndUnenrollAccount(...)
deRegisterAndUnenrollAccount(user: IntuneMAMUser) => Promise<void>Deregister the account from Intune and trigger selective wipe when applicable.
| Param | Type |
| ---------- | ------------------------------------------------------- |
| user | IntuneMAMUser |
logoutOfAccount(...)
logoutOfAccount(user: IntuneMAMUser) => Promise<void>Sign the user out of MSAL without unenrolling the Intune account.
| Param | Type |
| ---------- | ------------------------------------------------------- |
| user | IntuneMAMUser |
appConfig(...)
appConfig(user: IntuneMAMUser) => Promise<IntuneMAMAppConfig>Fetch the remote Intune app configuration for a managed account.
| Param | Type |
| ---------- | ------------------------------------------------------- |
| user | IntuneMAMUser |
Returns: Promise<IntuneMAMAppConfig>
getPolicy(...)
getPolicy(user: IntuneMAMUser) => Promise<IntuneMAMPolicy>Fetch the currently effective Intune app protection policy for a managed account.
| Param | Type |
| ---------- | ------------------------------------------------------- |
| user | IntuneMAMUser |
Returns: Promise<IntuneMAMPolicy>
groupName(...)
groupName(user: IntuneMAMUser) => Promise<IntuneMAMGroupName>Convenience helper that resolves the GroupName app configuration value when present.
| Param | Type |
| ---------- | ------------------------------------------------------- |
| user | IntuneMAMUser |
Returns: Promise<IntuneMAMGroupName>
sdkVersion()
sdkVersion() => Promise<IntuneMAMVersionInfo>Return the native Intune and MSAL SDK versions bundled by this plugin.
Returns: Promise<IntuneMAMVersionInfo>
displayDiagnosticConsole()
displayDiagnosticConsole() => Promise<void>Show the native Intune diagnostics UI.
addListener('appConfigChange', ...)
addListener(eventName: 'appConfigChange', listenerFunc: (info: IntuneMAMChangeEvent) => void) => Promise<PluginListenerHandle>Listen for remote app configuration refreshes.
| Param | Type |
| ------------------ | ---------------------------------------------------------------------------------------- |
| eventName | 'appConfigChange' |
| listenerFunc | (info: IntuneMAMChangeEvent) => void |
Returns: Promise<PluginListenerHandle>
addListener('policyChange', ...)
addListener(eventName: 'policyChange', listenerFunc: (info: IntuneMAMChangeEvent) => void) => Promise<PluginListenerHandle>Listen for remote app protection policy refreshes.
| Param | Type |
| ------------------ | ---------------------------------------------------------------------------------------- |
| eventName | 'policyChange' |
| listenerFunc | (info: IntuneMAMChangeEvent) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Remove all registered listeners for this plugin instance.
Interfaces
IntuneMAMAcquireToken
| Prop | Type |
| ----------------------- | ------------------- |
| accountId | string |
| accessToken | string |
| accountIdentifier | string |
| idToken | string |
| username | string |
| tenantId | string |
| authority | string |
AcquireTokenOptions
Interactive token acquisition options.
| Prop | Type | Description | Default |
| ----------------- | --------------------- | ---------------------------------------------------------------------- | ------------------ |
| scopes | string[] | Scopes to request, for example https://graph.microsoft.com/.default. | |
| forcePrompt | boolean | When true, always show the Microsoft account picker or sign-in UI. | false |
| loginHint | string | Optional login hint for the interactive sign-in flow. | |
AcquireTokenSilentOptions
Silent token acquisition options.
| Prop | Type | Description | Default |
| ------------------ | --------------------- | -------------------------------------------------------------------------- | ------------------ |
| scopes | string[] | Scopes to request, for example https://graph.microsoft.com/.default. | |
| accountId | string | Microsoft Entra object ID returned by acquireToken or enrolledAccount. | |
| forceRefresh | boolean | When true, bypass the cached access token and request a fresh one. | false |
RegisterAndEnrollAccountOptions
| Prop | Type | Description |
| --------------- | ------------------- | ----------------------------------------------------- |
| accountId | string | Microsoft Entra object ID returned by acquireToken. |
IntuneMAMUser
| Prop | Type |
| ----------------------- | ------------------- |
| accountId | string |
| accountIdentifier | string |
| username | string |
| tenantId | string |
| authority | string |
IntuneMAMAppConfig
| Prop | Type |
| --------------- | ----------------------------------------------------------------- |
| accountId | string |
| fullData | Record<string, string>[] |
| values | Record<string, string> |
| conflicts | string[] |
IntuneMAMPolicy
| Prop | Type |
| ------------------------------ | -------------------- |
| accountId | string |
| isPinRequired | boolean |
| isManagedBrowserRequired | boolean |
| isScreenCaptureAllowed | boolean |
| isContactSyncAllowed | boolean |
| isAppSharingAllowed | boolean |
| isFileEncryptionRequired | boolean |
| notificationPolicy | string |
IntuneMAMGroupName
| Prop | Type |
| --------------- | ------------------- |
| accountId | string |
| groupName | string |
IntuneMAMVersionInfo
| Prop | Type |
| ---------------------- | ------------------------------- |
| platform | 'ios' | 'android' |
| intuneSdkVersion | string |
| msalVersion | string |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
IntuneMAMChangeEvent
| Prop | Type |
| --------------- | ------------------- |
| accountId | string |
Type Aliases
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
