@napacitor/app-actions
App shortcuts plugin (corresponds to MAUI AppActions). Provides quick actions on the app icon (Android App Shortcuts / iOS home screen Quick Actions / Windows taskbar jump lists).
Installation
To use npm:
npm install @napacitor/app-actions
To use yarn:
yarn add @napacitor/app-actions
Sync native files:
npx nap sync
Usage
import { AppActions } from '@napacitor/app-actions';
// Check platform support, then set shortcuts (replaces the entire list)
const { supported } = await AppActions.isSupported();
if (supported) {
await AppActions.set({
actions: [
{ id: 'inbox', title: 'Inbox', subtitle: 'View new mail' },
{ id: 'compose', title: 'Compose' },
],
});
}
// Read the current shortcuts
const { actions } = await AppActions.get();
// Respond to shortcut taps
await AppActions.addListener('appActionPerformed', ({ action }) => {
console.log('Shortcut triggered:', action.id);
});
// Remove all listeners
await AppActions.removeAllListeners();
How It Works
Wraps the APIs described in the .NET MAUI AppActions documentation: AppActions.Default.SetAsync / GetAsync / IsSupported. MAUI's shortcut tap callback is registered at host startup (the plugin cannot subscribe on its own); the host must forward it to the plugin in MauiProgram.cs:
using Napacitor.Plugins.AppActions;
builder.ConfigureEssentials(essentials =>
{
essentials.OnAppAction(action => AppActionsPlugin.NotifyActionPerformed(action));
});
Hosts generated by nap init / nap add maui already include this forwarding (the template reflectively calls AppActionsPlugin.NotifyActionPerformed by type name, silently skipping when this plugin is not installed).
Permissions
Android
No permission declaration required, but Platforms/Android/MainActivity.cs needs an IntentFilter and two forwarding overrides. Without the IntentFilter, the launcher cannot resolve the shortcut intent and tapping a shortcut shows a system "app not installed" message. The Napacitor template includes this; custom hosts need to add it:
[Activity( /* ...existing template attributes... */ )]
[IntentFilter(new[] { Platform.Intent.ActionAppAction },
Categories = new[] { global::Android.Content.Intent.CategoryDefault })]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnResume()
{
base.OnResume();
Platform.OnResume(this);
}
protected override void OnNewIntent(Android.Content.Intent intent)
{
base.OnNewIntent(intent);
Platform.OnNewIntent(intent);
}
}
iOS / Mac Catalyst
No additional setup required when using the .NET MAUI app template.
Windows
No permission declaration required, but jump lists are only supported by MSIX-packaged apps (unpackaged apps with WindowsPackageType of None return false from isSupported()).
API
set(options)
Sets the app shortcuts (replaces the entire current list). Throws a FeatureNotSupported error when the platform does not support it (returned to JS as an error envelope).
| Param | Type |
|---|---|
options | SetOptions |
Returns: Promise<void>
get()
Gets the currently configured app shortcuts.
Returns: Promise<GetActionsResult>
isSupported()
Checks whether the current platform supports app shortcuts.
Returns: Promise<IsSupportedResult>
addListener('appActionPerformed', listenerFunc)
Dispatched when the user triggers a shortcut from the app icon. Requires the host to forward it in ConfigureEssentials (see How It Works), otherwise it never fires.
| Param | Type |
|---|---|
eventName | 'appActionPerformed' |
listenerFunc | (event: AppActionPerformed) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners()
Removes all listeners of this plugin.
Returns: Promise<void>
Interfaces
AppActionInfo
| Prop | Type | Description |
|---|---|---|
id | string | Unique identifier (used to distinguish actions when responding to taps). Must not be empty in set(), otherwise INVALID_ARGUMENTS is thrown. |
title | string | Display title. Must not be empty in set(), otherwise INVALID_ARGUMENTS is thrown. |
subtitle | string | Subtitle (shown below the title where supported). |
icon | string | Icon (must match icons in each platform's resource directory, consistent with the MAUI AppAction constructor); ignored where unsupported. Not returned by get() (MAUI AppAction does not expose an icon getter). |
SetOptions
| Prop | Type | Description |
|---|---|---|
actions | AppActionInfo[] | List of shortcuts to set (replaces the current list). |
GetActionsResult
| Prop | Type | Description |
|---|---|---|
actions | AppActionInfo[] | Currently configured shortcut list. |
IsSupportedResult
| Prop | Type | Description |
|---|---|---|
supported | boolean | Whether the current platform supports app shortcuts. |
AppActionPerformed
| Prop | Type | Description |
|---|---|---|
action | AppActionInfo | The shortcut that was triggered. |