@capawesome/capacitor-app-shortcuts

中文文档
8.0.3发布于 2026/10/09MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 8.7万

Capacitor plugin to manage app shortcuts and quick actions on Android and iOS.

原始使用文档
文档目录29 节
  1. Use Cases
  2. Compatibility
  3. Demo
  4. Installation
  5. Configuration
  6. Examples
  7. iOS
  8. Usage
  9. Create or update app shortcuts
  10. Get all app shortcuts
  11. Remove all app shortcuts
  12. Listen for shortcut clicks
  13. API
  14. clear()
  15. get()
  16. set(...)
  17. addListener('click', ...)
  18. removeAllListeners()
  19. Interfaces
  20. FAQ
  21. Which platforms are supported by this plugin?
  22. Why is the click listener not called on iOS?
  23. Can I define app shortcuts without writing any code?
  24. Can I use different icons on Android and iOS?
  25. Can I use this plugin with Ionic, React, Vue or Angular?
  26. Related Plugins
  27. Newsletter
  28. Changelog
  29. License

Capacitor App Shortcuts Plugin

Capacitor plugin to manage app shortcuts and quick actions.

Use Cases

The App Shortcuts plugin is typically used to give users faster access to key parts of your app right from the home screen icon, for example:

  • Quick actions: Let users jump directly to frequently used screens such as search, compose, or feedback.
  • Dynamic shortcuts: Create or update shortcuts at runtime based on user behavior, for example a shortcut to the most recently opened item.
  • Default shortcuts: Define a set of default shortcuts in your Capacitor configuration without writing any code.
  • Deep linking: React to shortcut clicks with the click listener and navigate the user to the corresponding screen.

Compatibility

Plugin VersionCapacitor VersionStatus
8.x.x>=8.x.xActive support

Demo

A working example can be found here.

AndroidiOS

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

 Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-app-shortcuts` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands:

npm install @capawesome/capacitor-app-shortcuts
npx cap sync

Configuration

PropTypeDescriptionSince
shortcutsShortcut[]The list of app shortcuts that should be set by default. Only available on Android and iOS.7.2.0

Examples

In capacitor.config.json:

{
  "plugins": {
    "AppShortcuts": {
      "shortcuts": [{ id: 'feedback', title: 'Feedback' }]
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capawesome/capacitor-app-shortcuts" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    AppShortcuts: {
      shortcuts: [{ id: 'feedback', title: 'Feedback' }],
    },
  },
};

export default config;

iOS

If your app uses the UIScene lifecycle (default since Capacitor 8.5), add the following to your app's SceneDelegate.swift:

+ import AppShortcutsPlugin

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene else { return }

        window = UIWindow(windowScene: windowScene)
        window?.rootViewController = CAPBridgeViewController()
        window?.makeKeyAndVisible()

+        if let shortcutItem = connectionOptions.shortcutItem {
+            NotificationCenter.default.post(name: NSNotification.Name(AppShortcutsPlugin.notificationName), object: nil, userInfo: [AppShortcutsPlugin.userInfoShortcutItemKey: shortcutItem])
+        }

        SceneDelegateProxy.shared.scene(scene, willConnectTo: session, options: connectionOptions)
    }

+    func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
+        NotificationCenter.default.post(name: NSNotification.Name(AppShortcutsPlugin.notificationName), object: nil, userInfo: [AppShortcutsPlugin.userInfoShortcutItemKey: shortcutItem])
+        completionHandler(true)
+    }

If your app does not use the UIScene lifecycle, add the following to your app's AppDelegate.swift instead:

+ import AppShortcutsPlugin

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
+        if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem {
+            NotificationCenter.default.post(name: NSNotification.Name(AppShortcutsPlugin.notificationName), object: nil, userInfo: [AppShortcutsPlugin.userInfoShortcutItemKey: shortcutItem])
+            return false
+        }
        return true
    }

+    func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
+        NotificationCenter.default.post(name: NSNotification.Name(AppShortcutsPlugin.notificationName), object: nil, userInfo: [AppShortcutsPlugin.userInfoShortcutItemKey: shortcutItem])
+        completionHandler(true)
+    }

If your project still uses CocoaPods instead of Swift Package Manager (SPM), import CapawesomeCapacitorAppShortcuts rather than AppShortcutsPlugin:

+ import CapawesomeCapacitorAppShortcuts

Usage

The following examples show how to create, get, and remove app shortcuts and listen for shortcut clicks.

Create or update app shortcuts

Use the set(...) method to create or update the app shortcuts. Each shortcut needs a unique identifier and a title. Only available on Android and iOS:

import { AppShortcuts } from '@capawesome/capacitor-app-shortcuts';

const set = async () => {
  await AppShortcuts.set({
    shortcuts: [
      {
        id: 'feedback',
        title: 'Feedback',
        description: 'Send us your feedback',
      },
      {
        id: 'rate',
        title: 'Rate',
        description: 'Rate our app',
      }
    ],
  });
};

Get all app shortcuts

Retrieve the list of app shortcuts that are currently set. Only available on Android and iOS:

import { AppShortcuts } from '@capawesome/capacitor-app-shortcuts';

const get = async () => {
  const result = await AppShortcuts.get();
  return result.shortcuts;
};

Remove all app shortcuts

Clear all app shortcuts, for example when the user signs out. Only available on Android and iOS:

import { AppShortcuts } from '@capawesome/capacitor-app-shortcuts';

const clear = async () => {
  await AppShortcuts.clear();
};

Listen for shortcut clicks

Add a listener for the click event to react when the user taps an app shortcut, for example to navigate to the corresponding screen. On iOS, this requires the changes to your AppDelegate.swift described in the iOS configuration instructions:

import { AppShortcuts } from '@capawesome/capacitor-app-shortcuts';

const addListener = async () => {
  AppShortcuts.addListener('click', (event) => {
    console.log('Shortcut clicked:', event.shortcutId);
  });
};

API

clear()

clear() => Promise<void>

Remove all app shortcuts.

Only available on Android and iOS.

Since: 6.0.0


get()

get() => Promise<GetResult>

Get all app shortcuts.

Only available on Android and iOS.

Returns: Promise<GetResult>

Since: 6.0.0


set(...)

set(options: SetOptions) => Promise<void>

Create or update app shortcuts.

Only available on Android and iOS.

ParamType
optionsSetOptions

Since: 6.0.0


addListener('click', ...)

addListener(eventName: 'click', listenerFunc: (event: ClickEvent) => void) => Promise<PluginListenerHandle>

Called when an app shortcut is clicked.

Only available on Android and iOS.

ParamType
eventName'click'
listenerFunc(event: ClickEvent) => void

Returns: Promise<PluginListenerHandle>

Since: 6.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 6.0.0


Interfaces

GetResult

PropTypeDescriptionSince
shortcutsShortcut[]The list of app shortcuts.6.0.0

Shortcut

PropTypeDescriptionSince
descriptionstringThe description. On Android, the launcher shows this instead of the short title when it has enough space.6.0.0
idstringThe unique identifier.6.0.0
titlestringThe display name.6.0.0
iconstring | numberThe icon to display. On Android, the icon can be one of the following: - An integer value of the R.drawable enum (e.g. 17301547). - A string that represents the name of the drawable resource (e.g. "alert_dark_frame"). - A base64 encoded image string (e.g. "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QC..."). On iOS, the icon can be one of the following: - The constant integer value of the UIApplicationShortcutIcon.IconType enum (e.g. 6). - A system symbol name (e.g. star.fill). - Name of the image asset from the asset catalogue.6.1.0
androidIconstring | numberThe icon to display on Android. The icon can be one of the following: - An integer value of the R.drawable enum (e.g. 17301547). - A string that represents the name of the drawable resource (e.g. "alert_dark_frame"). - A base64 encoded image string (e.g. "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QC...").7.2.0
iosIconstring | numberThe icon to display on iOS. The icon can be one of the following: - The constant integer value of the UIApplicationShortcutIcon.IconType enum (e.g. 6). - A system symbol name (e.g. star.fill). - Name of the image asset from the asset catalogue.7.2.0

SetOptions

PropTypeDescriptionSince
shortcutsShortcut[]The list of app shortcuts.6.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

ClickEvent

PropTypeDescriptionSince
shortcutIdstringThe unique identifier of the app shortcut that was clicked.6.0.0

FAQ

Which platforms are supported by this plugin?

App shortcuts are a native concept of the Android launcher and the iOS home screen, so the plugin is only available on Android and iOS. All plugin methods and the click event are marked as only available on Android and iOS in the API section.

Why is the click listener not called on iOS?

On iOS, the plugin relies on changes to your app's AppDelegate.swift to forward shortcut items to the plugin. Make sure you have applied the code changes described in the iOS configuration instructions. Without them, the click event is never delivered.

Can I define app shortcuts without writing any code?

Yes, you can use the shortcuts configuration option to define a list of app shortcuts that are set by default. See the Configuration section for examples in capacitor.config.json and capacitor.config.ts.

Can I use different icons on Android and iOS?

Yes, you can use the androidIcon and iosIcon properties to provide platform-specific icons, or the icon property for both platforms. On Android, drawable resources and base64 encoded images are supported, while on iOS you can use system symbol names, asset catalogue images, or UIApplicationShortcutIcon types. Note that on iOS, the icon and the description must be used together.

Can I use this plugin with Ionic, React, Vue or Angular?

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

  • App Icon: Change the app icon at runtime.
  • Badge: Access and update the badge number of the app icon.

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.

版本与发布记录

@capawesome/capacitor-app-shortcuts 共发布 14 个版本,首次发布于 2024/12/19;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.3latest2026/10/0930 天前
8.0.22026/09/022 个月前
8.0.12026/02/198 个月前
8.0.02025/12/1710 个月前
7.0.0-dev.1765885034dev2025/12/1610 个月前
7.5.02025/06/021.4 年前

关于 @capawesome/capacitor-app-shortcuts 的常见问题

@capawesome/capacitor-app-shortcuts 是什么?

Capacitor plugin to manage app shortcuts and quick actions on Android and iOS.

如何安装 @capawesome/capacitor-app-shortcuts?

在项目目录运行 npm install @capawesome/capacitor-app-shortcuts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capawesome/capacitor-app-shortcuts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capawesome/capacitor-app-shortcuts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capawesome/capacitor-app-shortcuts 可以商用吗?

@capawesome/capacitor-app-shortcuts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capawesome/capacitor-app-shortcuts 的下载量有多少?

根据 npm 官方下载统计,@capawesome/capacitor-app-shortcuts 在 2026/10/09 – 2026/11/07 这 30 天内被下载 86,843 次,日均约 2,895 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capawesome/capacitor-app-shortcuts 还在维护吗?

最新版本 8.0.3 发布于 2026/10/09(30 天前);至今共发布 14 个版本,其中过去 12 个月发布了 5 个;首次发布于 2024/12/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。