Version 6 of this Plugin only works with Capacitor 6.
npm i capacitor-plugin-siri-shorts@5.0.0
.npm i capacitor-plugin-siri-shorts@3.0.0
.npm i capacitor-plugin-siri-shorts@1.0.3
.The Plugin requires at least iOS 12 and Xcode 10.
npm i capacitor-plugin-siri-shorts
Add a new Item to NSUserActivityTypes
inside your Info.plist
with your Bundle Identifier:
$(PRODUCT_BUNDLE_IDENTIFIER).shortcut
Extend the application:continueuserActivity,restorationHandler
function inside your AppDelegate.swift
with the following line:
NotificationCenter.default.post(Notification(name: Notification.Name(rawValue: "appLaunchBySiriShortcuts"), object: userActivity, userInfo: userActivity.userInfo))
Put this line before the return statement!
The function should look similar to that:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
NotificationCenter.default.post(Notification(name: Notification.Name(rawValue: "appLaunchBySiriShortcuts"), object: userActivity, userInfo: userActivity.userInfo))
return CAPBridge.handleContinueActivity(userActivity, restorationHandler)
}
Basic example of the donate function:
import { SiriShortcuts } from 'capacitor-plugin-siri-shorts';
...
someAction() {
SiriShortcuts.donate({
persistentIdentifier: "someIdentifier",
title: "A descriptive title"
})
}
It's recommended to add a listener into the initializeApp()
function inside app.component.ts
.
initializeApp() {
this.platform.ready().then(() => {
...
SiriShortcuts.addListener('appLaunchBySiriShortcuts', (res) => {
// do something with the response of the shortcut here
console.log(res)
});
});
}
Options
| Options to specify for the donation |
**Returns:** Promise<any>
**Since:** 1.0.0
--------------------
### present(...)
```typescript
present(options: Options) => PromiseOptions
| Options to specify for the donation |
**Returns:** Promise<any>
**Since:** 2.2.0
--------------------
### delete(...)
```typescript
delete(options: DeleteOptions) => PromiseDeleteOptions
|
**Since:** 2.1.0
--------------------
### deleteAll()
```typescript
deleteAll() => Promise'appLaunchBySiriShortcuts'
| Name of the event |
| **`listenerFunc`** | (shortcut: Shortcut) => void
| Function to execute when listener gets notified |
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
**Since:** 2.0.1
--------------------
### removeAllListeners()
```typescript
removeAllListeners() => Promisestring
| Specify an identifier to uniquely identify the shortcut, in order to be able to remove it |
| **`title`** | string
| Specify a title for the shortcut, which is visible to the user as the name of the shortcut |
| **`userInfo`** | UserInfo
| Provide a key-value object that contains information about the shortcut, this will be returned in the getActivatedShortcut method. It is not possible to use the persistentIdentifier key, it is used internally |
| **`suggestedInvocationPhrase`** | string
| Specify the phrase to give the user some inspiration on what the shortcut to call |
| **`isEligibleForSearch`** | boolean
| This value defaults to true, set this value to make it searchable in Siri |
| **`isEligibleForPrediction`** | boolean
| This value defaults to true, set this value to set whether the shortcut eligible for prediction |
#### UserInfo
#### DeleteOptions
Options to specify for a deletion
| Prop | Type | Description |
| ----------------- | --------------------- | ------------------------------------------------------- |
| **`identifiers`** | string[]
| Array of persistent identifiers which should be deleted |
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | () => Promise<void>
|
#### Shortcut
Object which will be returned by the listener which
contains the persistent identifier and the userinfo
of a shortcut
| Prop | Type |
| -------------------------- | ------------------- |
| **`persistentIdentifier`** | string
|