> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Dynamics

> Send Microsoft Dynamics 365 Customer Insights push notifications to your app, and manage permissions and device registration with the JavaScript Bridge.

> [!NOTE]
>
> **Enterprise plugin**
>
> The Microsoft Dynamics integration is available on Median's [Business and Enterprise plans](https://median.co/pricing#business). These plans include expert app development, advanced native plugin access, dedicated technical support, and guaranteed App Store publishing.

The Microsoft Dynamics plugin connects your Median app to Dynamics 365 Customer Insights – Journeys (formerly Dynamics 365 Marketing), giving you JavaScript Bridge control over push permission flows, device registration, and APNS/FCM token management. Use this plugin when your organization runs customer journey orchestration in Dynamics and needs to reach users with native push notifications.

The plugin exposes a lightweight [Median JavaScript Bridge](https://docs.median.co/docs/javascript-bridge.md) surface that covers the full push lifecycle: prompting for permission, querying permission state, registering a device-user binding with Dynamics, and retrieving the registration metadata your Dynamics environment expects for targeting and troubleshooting.

## Why use Microsoft Dynamics

* **Unified push in your Dynamics ecosystem**: Extend real-time customer journeys into mobile without a separate push provider. Push notifications are orchestrated directly from Dynamics 365 Customer Insights – Journeys alongside your email, SMS, and in-app channels.
* **Bridge-first permission control**: Request and check push notification permission entirely from JavaScript, giving you full control over the timing and context of the permission prompt without writing native code.
* **Precise user-device binding**: Register a specific `userId` against the device token so Dynamics campaigns target the right profile. This is essential for enterprises with strict user-identity requirements.
* **Token and metadata transparency**: Retrieve APNS and FCM tokens plus rich device metadata (`installationId`, `os`, `model`, `timeZone`) for registration audits, support workflows, and cross-channel attribution.

## Prerequisites

* A Median app with the [JavaScript Bridge](https://docs.median.co/docs/javascript-bridge.md) enabled
* A licensed Dynamics 365 Customer Insights – Journeys environment with mobile push configured
* Push channel setup completed in Dynamics 365 Marketing (iOS APNS certificate or token + Android FCM server key)
* Alphanumeric user identifiers (UUIDs) available at the point of registration in your web application

## Key terms

The following terms are specific to the Microsoft Dynamics push integration and will help you implement the plugin correctly:

**Customer Insights – Journeys**: The Dynamics 365 module (formerly Dynamics 365 Marketing) is responsible for real-time marketing journeys, including push notification delivery. Push configuration and campaign management happen here.

**Mobile app channel**: A Dynamics 365 configuration entity that stores your iOS APNS and Android FCM credentials, links them to a Dynamics environment, and issues the channel ID used during device registration.

**APNS token**: The Apple Push Notification Service device token issued to an iOS device. Returned by `registrationInfo` and required by Dynamics to deliver push to that device.

**FCM token**: The Firebase Cloud Messaging registration token issued to an Android device. Returned by `registrationInfo` and required by Dynamics to deliver push to that device.

**Installation ID**: A Dynamics-side identifier that uniquely tracks a device-user pair within your mobile app channel. Returned in `registrationInfo` and useful for support lookups and registration audits.

**Important considerations**

* On **Android 13 (API 33) and above**, the system displays a push permission dialog when you call `promptNotificationPermission`. On Android 12 and below, permission is granted automatically without a user dialog.
* On **iOS**, the system prompt is shown once per app install. If a user has previously denied permission, you can't re-prompt. Direct users to **Settings** instead.
* The `userId` passed to `registerDevice` should be a stable, alphanumeric UUID that matches the contact identifier in your Dynamics environment. Mismatched identifiers cause targeting failures in journeys.

## Integration guide

### Enable the plugin

1. **Open your app in Median App Studio**: Go to **Native Plugins**.
2. **Enable Microsoft Dynamics 365**: Turn on the plugin and enter the values from your Dynamics mobile app configuration in the plugin settings.
3. **Save and rebuild**: Save your configuration. A new build is required for the plugin to be active.

### Configuration options

Copy these values from the mobile app configuration in Dynamics 365 Customer Insights – Journeys.

| Setting | Description |
| - | - |
| **Mobile App ID** | ID of the mobile app configuration in Dynamics. |
| **Organization ID** | ID of your Dynamics 365 organization. |
| **Public Endpoint URL** | Endpoint the app uses to register devices with Dynamics. |
| **API Access Token** | Token that authorizes the app's requests to that endpoint. |

> [!WARNING]
>
> **All four settings are required**
>
> If a value is missing or empty, device registration fails and the JavaScript Bridge returns an error. Fill in all four settings before you rebuild.

## JavaScript Bridge functions

Only `promptNotificationPermission` and `areNotificationsEnabled` are documented with an **optional callback or returned promise**. On the JavaScript Bridge, a callback is normally passed as a **`callback` property inside the options object**, not as a second function parameter.

If `await` on `registerDevice` or `registrationInfo` does not behave as expected in your build, call them without `await` and use a `callback` property or `.then()` only after confirming what the JavaScript Bridge returns.

### Prompt for push notification permission

Requests push notification permission from the user. On **Android 13+**, this displays the system permission dialog. On **Android 12 and below**, permission is granted silently. On **iOS**, the system authorization dialog is presented.

Provide a callback or use the returned promise.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Using promises (recommended)
const result = await median.msdynamics.promptNotificationPermission();
console.log("Permission granted:", result.granted);

// Using a callback
median.msdynamics.promptNotificationPermission({
  callback: function (result) {
    console.log("Permission granted:", result.granted);
  },
});
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `callback` | `function` | No | Optional callback function. If omitted, a promise is returned. |

**Return value:**

Median JavaScript Bridge

```typescript TypeScript theme={null}
interface PermissionResult {
  granted: boolean; // true if push permission is granted, false otherwise
}
```

### Check push notification permission status

Checks the current push notification permission status without prompting the user. Use this to gate push-related UI or analytics before prompting or registering.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Using promises (recommended)
const result = await median.msdynamics.areNotificationsEnabled();
if (result.granted) {
  // Show push-related settings or proceed with registration
}

// Using a callback
median.msdynamics.areNotificationsEnabled({
  callback: function (result) {
    console.log("Notifications enabled:", result.granted);
  },
});
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `callback` | `function` | No | Optional callback function. If omitted, a promise is returned. |

**Return value:**

Median JavaScript Bridge

```typescript TypeScript theme={null}
interface PermissionResult {
  granted: boolean; // true if notifications are currently enabled, false otherwise
}
```

### Register device

Registers a new user-device pair with Microsoft Dynamics or updates an existing registration. Call this after your user authenticates so the device token is bound to the correct Dynamics contact record.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Using promises (recommended)
const result = await median.msdynamics.registerDevice({
  userId: "abc123-user-uuid",
});
if (result.success) {
  console.log("Device registered with Dynamics");
}

// Using a callback
median.msdynamics.registerDevice(
  { userId: "abc123-user-uuid" },
  function (result) {
    console.log("Registration result:", result.success);
  },
);
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `userId` | `string` | Yes | Alphanumeric UUID that identifies the user in your Dynamics environment. Must match the contact identifier used in your Dynamics journeys. |

**Return value:**

Median JavaScript Bridge

```typescript TypeScript theme={null}
interface RegisterDeviceResult {
  success: boolean; // true if registration succeeded, false otherwise
}
```

### Return registration info

Returns the full registration and device metadata for the current app installation. Use this to retrieve APNS/FCM tokens for passing to Dynamics, to verify registration state, or for support and compliance audits.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Using promises (recommended)
const info = await median.msdynamics.registrationInfo();
console.log("Platform:", info.platform);
console.log("APNS Token:", info.apnsToken); // iOS only
console.log("FCM Token:", info.fcmToken); // Android only
console.log("Installation ID:", info.installationId);
```

**Parameters:**

None.

**Return value:**

```typescript TypeScript theme={null}
interface RegistrationInfo {
  apnsToken?: string; // iOS only — Apple Push Notification Service device token
  fcmToken?: string; // Android only — Firebase Cloud Messaging registration token
  platform: string; // 'ios' or 'android'
  appId: string; // Bundle ID / package name of the app
  appVersion: string; // App version string (e.g. '1.0.0')
  appBuild: string; // Build number (string on iOS, appVersionCode number on Android)
  distribution: string; // 'release' or 'debug'
  hardware: string; // CPU architecture (e.g. 'armv8')
  installationId: string; // Dynamics installation identifier for this device-user pair
  language: string; // Device locale language code (e.g. 'en')
  model: string; // Device model name (e.g. 'iPhone')
  os: string; // Operating system name (e.g. 'iOS' or 'Android')
  osVersion: string; // OS version string (e.g. '17.0')
  timeZone: string; // IANA timezone identifier (e.g. 'America/New_York')
  isFirstLaunch: boolean; // true if this is the first launch of the app
}
```

## Testing checklist

Use this checklist to ensure Microsoft Dynamics is working correctly in your app:

**Basic functionality**

* [ ] `promptNotificationPermission` displays the system dialog on Android 13+ and iOS
* [ ] `promptNotificationPermission` returns `{ granted: true }` after user accepts
* [ ] `areNotificationsEnabled` returns `{ granted: true }` when permissions are active
* [ ] `areNotificationsEnabled` returns `{ granted: false }` when permissions are denied
* [ ] `registerDevice` returns `{ success: true }` with a valid `userId`
* [ ] `registrationInfo` returns a populated object with all expected fields

**Platform testing**

* [ ] APNS token is present in `registrationInfo` on an iOS device
* [ ] FCM token is present in `registrationInfo` on an Android device
* [ ] `isFirstLaunch` is `true` on first app launch and `false` on subsequent launches
* [ ] `promptNotificationPermission` on Android 12 and below returns `granted: true` without a dialog

**Dynamics end-to-end**

* [ ] Device registration is reflected in the Dynamics 365 Customer Insights – Journeys mobile app channel
* [ ] A test push notification sent from Dynamics is received on an iOS test device
* [ ] A test push notification sent from Dynamics is received on an Android test device
* [ ] Tapping a notification opens the correct URL or in-app destination

**Edge cases**

* [ ] Calling `registerDevice` before push permission is granted does not cause a crash
* [ ] Calling `registrationInfo` before `registerDevice` returns a populated object (no null reference)
* [ ] Re-calling `registerDevice` with the same `userId` succeeds (idempotent update)
* [ ] App handles `{ success: false }` from `registerDevice` without a UI crash

## Troubleshooting

### Microsoft Dynamics JavaScript Bridge functions are undefined or not working

Ensure the JavaScript Bridge is enabled in App Studio and that you are calling JavaScript Bridge functions after the page has fully loaded. Also verify that the Microsoft Dynamics plugin is enabled under **Native Plugins** in App Studio and that a new build has been generated after enabling it.

### Push permission dialog is not appearing on Android

On **Android 12 and below**, permission is granted automatically and no system dialog is shown. The dialog only appears on **Android 13 (API 33) and above**. If you expect a dialog on Android 12, this is expected behavior. Verify the OS version of the test device and adjust your UX flow to handle the silent-grant path gracefully.

### `registerDevice` returns `{ success: false }` or fails silently

Check the following: push notification permission has been granted before calling `registerDevice` (use `areNotificationsEnabled` first); the `userId` passed is a stable alphanumeric UUID that matches your Dynamics contact identifiers; and your Dynamics 365 mobile app channel has APNS (iOS) and/or FCM (Android) credentials correctly configured. Mismatched or missing credentials on the Dynamics side will cause registration to fail.

### Device registration is not appearing in Dynamics 365

Confirm that your Dynamics 365 Customer Insights – Journeys environment has the mobile app channel configured with the correct APNS and FCM credentials. Verify that the `userId` passed to `registerDevice` matches an existing contact record identifier in Dynamics. If registration completes with `{ success: true }` but the device does not appear in Dynamics, the issue is likely on the Dynamics configuration side. Check the mobile app channel settings and consult Dynamics push setup documentation.

### Push notifications are not being delivered to the device

Verify that `registrationInfo` returns populated `apnsToken` (iOS) or `fcmToken` (Android) fields. A missing token means the device is not registered for push. Confirm push permission is granted with `areNotificationsEnabled`. On the Dynamics side, ensure the journey or message is targeting the correct segment and that the mobile app channel is active. For Android, check that `google-services.json` is uploaded in **App Studio → Build & Deploy**.

### `registrationInfo` returns empty or null token fields

Token fields (`apnsToken`, `fcmToken`) are only populated after `registerDevice` has been called successfully and push permission has been granted. Call `promptNotificationPermission` and confirm permission is granted, then call `registerDevice` with a valid `userId` before querying `registrationInfo`. If tokens remain empty after a successful registration, rebuild the app in App Studio to ensure the latest plugin configuration is included.

> [!NOTE]
>
> **Still having trouble?**
>
> For issues related to Microsoft Dynamics' own configuration, permissions, or platform-specific behavior outside of Median, refer to [Microsoft Dynamics' integration documentation](https://learn.microsoft.com/en-us/dynamics365/customer-insights/journeys/push-notifications-setup).


## Related topics

- [Changelog](https://docs.median.co/docs/changelog.md)
- [Push notifications overview](https://docs.median.co/docs/push-notifications-overview.md)
- [Microsoft Intune](https://docs.median.co/docs/microsoft-intune.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.