Skip to content

Android Setup

GitHub

In your app project’s top-level android/build.gradle, add the Intune Gradle plugin JAR to the buildscript classpath. The plugin package includes:

  • android/ms-intune-app-sdk-android/GradlePlugin/com.microsoft.intune.mam.build.jar

Also include the Duo Maven feed that Ionic documents for current Intune Android SDK releases:

maven {
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
name 'Duo-SDK-Feed'
}

In android/app/build.gradle:

apply plugin: 'com.microsoft.intune.mam'

And keep resource optimization disabled:

android.enableResourceOptimizations=false

Create android/app/src/main/res/raw/auth_config.json:

{
"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"
}
}
]
}

The plugin expects that file at runtime for both MSAL and the Intune auth callback.

If your app does not already define a custom Application, set:

<application
android:name="app.capgo.intune.IntuneApplication"
android:enableOnBackInvokedCallback="false">

If you already have a custom Application, extend MAMApplication and register IntuneMamServiceAuthenticationCallback in onMAMCreate().

5. Add broker auth queries and redirect handling

Section titled “5. Add broker auth queries and redirect handling”

Add the package visibility queries Ionic documents for:

  • com.azure.authenticator
  • com.microsoft.windowsintune.companyportal
  • browser detection intents

Also add BrowserTabActivity with your msauth:// redirect URI host/path so MSAL can complete the sign-in round trip.

Once the app-level native setup is complete, the Capacitor API is the same as on iOS:

import { IntuneMAM } from '@capgo/capacitor-intune';
const auth = await IntuneMAM.acquireToken({
scopes: ['https://graph.microsoft.com/.default'],
});
await IntuneMAM.registerAndEnrollAccount({
accountId: auth.accountId,
});

If you are using Android Setup to plan native plugin work, connect it with Using @capgo/capacitor-intune for the native capability in Using @capgo/capacitor-intune, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, and Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives.