Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukasandreano/capacitor-quick-actions
A Capacitor plugin that allows you to use the Quick Actions API on iOS/iPadOS
https://github.com/lukasandreano/capacitor-quick-actions
capacitor ios quick-actions quickactions
Last synced: 2 days ago
JSON representation
A Capacitor plugin that allows you to use the Quick Actions API on iOS/iPadOS
- Host: GitHub
- URL: https://github.com/lukasandreano/capacitor-quick-actions
- Owner: LukasAndreano
- Created: 2024-06-13T14:07:17.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-14T21:12:19.000Z (5 months ago)
- Last Synced: 2024-10-30T22:27:48.280Z (15 days ago)
- Topics: capacitor, ios, quick-actions, quickactions
- Language: Swift
- Homepage: https://npmjs.com/package/capacitor-quick-actions
- Size: 1.92 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Capacitor Quick Actions
Plugin for using [Quick Actions](https://developer.apple.com/documentation/uikit/menus_and_shortcuts/add_home_screen_quick_actions#3701696) in your Capacitor Apps.
Now it supports only on iOS/iPadOS 13+.![](https://github.com/lukasandreano/capacitor-quick-actions/blob/main/docs/preview.png?raw=true)
## Install
```bash
npm install capacitor-quick-actions
npx cap sync
```## Preparation
Modify your `AppDelegate.swift`:
1. Add `import CapacitorQuickActions` to the top of the file.
2. Add `application function` to the bottom of the file:
```swift
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let handled = QuickActions.handleQuickAction(shortcutItem)
completionHandler(handled)
}
```
Example of the `AppDelegate.swift` file available [here](https://github.com/lukasandreano/capacitor-quick-actions/blob/main/docs/AppDelegate.swift).## Usage
```typescript
// Import the plugin
import { QuickActions } from 'capacitor-quick-actions';// Add buttons to the home screen
const addButtonsToHomeScreen = async () => {
await QuickActions.addQuickActions({
actions: [
{ id: "button1", title: 'Action1', iconName: 'house', description: 'Description1' },
{ id: "button2", title: 'Action2', iconName: '2' } // Description is optional
]
});
}// Remove buttons from the home screen
const clearButtonsFromHomeScreen = async () => {
await QuickActions.clearQuickActions();
}// Add Listener for the selected action
QuickActions.addListener('quickActionSelected', (data) => {
console.log('Quick Action selected:', data.type); // returns id of the selected action
});
```## Icons
To use icons in your quick actions provide the name of the icon from [this app](https://developer.apple.com/sf-symbols/).## API
* [`addQuickActions(...)`](#addquickactions)
* [`clearQuickActions()`](#clearquickactions)
* [`addListener('quickActionSelected', ...)`](#addlistenerquickactionselected-)
* [Interfaces](#interfaces)### addQuickActions(...)
```typescript
addQuickActions(options: { actions: QuickAction[]; }) => Promise
```| Param | Type |
| ------------- | ---------------------------------------- |
| **`options`** |{ actions: QuickAction[]; }
|--------------------
### clearQuickActions()
```typescript
clearQuickActions() => Promise
```--------------------
### addListener('quickActionSelected', ...)
```typescript
addListener(eventName: 'quickActionSelected', listenerFunc: (data: { type: string; }) => void) => PluginListenerHandle
```| Param | Type |
| ------------------ | ------------------------------------------------- |
| **`eventName`** |'quickActionSelected'
|
| **`listenerFunc`** |(data: { type: string; }) => void
|**Returns:**
PluginListenerHandle
--------------------
### Interfaces
#### QuickAction
| Prop | Type |
| ----------------- | ------------------- |
| **`id`** |string
|
| **`title`** |string
|
| **`iconName`** |string
|
| **`description`** |string
|#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** |() => Promise<void>
|