Implement Actionable Notifications

Mobile SDK apps can use the Salesforce Notifications API to implement actionable notifications: push notifications that include interactive action buttons the user can tap directly from the notification tray, without opening the app.

Before displaying actionable notifications, retrieve the notification types defined for your org. Each notification type describes the notification’s appearance and its list of available actions.

The Notifications API endpoint is GET /{apiVersion}/connect/notifications/types.

Use PushNotificationManager to fetch and cache notification types.

The fetchAndStoreNotificationTypes() method:

  • Fetches notification types from the Notifications API.
  • Caches them to disk for offline use.
  • Automatically registers the notification categories with iOS through UNUserNotificationCenter.

For custom handling, use the low-level API instead.

Use SalesforceSDKManager to fetch notification types.

Register Android notification channels

After fetching notification types, register them as Android notification channels. Typically, call this from your Application.onCreate() method, after Mobile SDK initialization.

This code creates a notification channel for each type and groups the channels under “Salesforce Notifications”.

See also: Notifications Resources.

Register the notification categories (iOS) or channels with action buttons (Android) using the action data that you retrieved.

Mobile SDK automatically registers notification categories when you call fetchAndStoreNotificationTypes(). Behind the scenes, it uses NotificationCategoryFactory to convert notification types into UNNotificationCategory and UNNotificationAction objects.

If you want to filter which notification types are registered—for example, only certain types for certain users—set a filter on UserAccountManager.

For reference, here’s how Mobile SDK registers categories with iOS under the hood.

Mobile SDK automatically registers a notification channel for each notification type after push registration succeeds. When you build a notification, use the notification type’s type value as the channel ID. Add action buttons dynamically when you build the notification in your PushNotificationReceiver or PushNotificationsAdapter.

The Mobile SDK template app includes a full example in PushNotificationsAdapter.kt.

When the user taps a notification action, handle it in your app delegate (iOS) or broadcast receiver (Android).

Implement UNUserNotificationCenterDelegate in your AppDelegate.

Set the delegate in application(_:didFinishLaunchingWithOptions:).

Register a BroadcastReceiver to handle notification actions.

Register the receiver in your Application.onCreate().

The Notifications API endpoint is POST /{apiVersion}/connect/notifications/{notificationId}/actions/{actionKey}.

Use PushNotificationManager.invokeServerNotificationAction().

For multi-user apps, use a custom RestClient.

Use SalesforceSDKManager.invokeServerNotificationAction().

For multi-user apps, use a custom RestClient.

Client-side actions run entirely in the app and don’t require a server call. Implement them in the standard platform notification delegate methods.

Check the action identifier in userNotificationCenter(_:didReceive:withCompletionHandler:) and handle client-side actions before calling the server API.

In your BroadcastReceiver, check the action type and handle client-side actions.

These models represent the notification types and actions that the Notifications API returns.

Mobile SDK 14.0 includes complete sample apps that demonstrate actionable notifications end to end.

  • Android: Android Native Kotlin Template, including PushNotificationsAdapter.kt, InvokeNotificationActionBroadcastIntentReceiver, and notification channel registration.
  • iOS: iOS Native Swift Encrypted Notification Template, a SwiftUI app with AppDelegate implementing UNUserNotificationCenterDelegate and server action invocation.