npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-plugin-siri-shorts

v6.0.0

Published

Capacitor Plugin for Siri Shortcuts

Downloads

256

Readme

ios xcode npm GitHub npm capacitor

Capacitor Plugin for Siri Shortcuts

💥 Breaking Changes

Version 6 of this Plugin only works with Capacitor 6.

🔧 Setup

The Plugin requires at least iOS 12 and Xcode 10.

npm i capacitor-plugin-siri-shorts

iOS Project

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)
}

✨ Example Usage

A full Ionic + Angular example is available here

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)
    });
  });
}

🏗️ API Reference

donate(...)

donate(options: Options) => Promise<any>

Donates the provided action to Siri/Shortcuts

| Param | Type | Description | | ------------- | ------------------------------------------- | ---------------------------------------------------------- | | options | Options | Options to specify for the donation |

Returns: Promise<any>

Since: 1.0.0


present(...)

present(options: Options) => Promise<any>

Presents a modal to the user to add the shortcut to siri and access it via voice

| Param | Type | Description | | ------------- | ------------------------------------------- | ---------------------------------------------------------- | | options | Options | Options to specify for the donation |

Returns: Promise<any>

Since: 2.2.0


delete(...)

delete(options: DeleteOptions) => Promise<void>

Deletes the previous donations with the provided persistent identifiers

| Param | Type | | ------------- | ------------------------------------------------------- | | options | DeleteOptions |

Since: 2.1.0


deleteAll()

deleteAll() => Promise<void>

Delets all the previously donated activities

Since: 2.1.0


addListener('appLaunchBySiriShortcuts', ...)

addListener(eventName: 'appLaunchBySiriShortcuts', listenerFunc: (shortcut: Shortcut) => void) => Promise<PluginListenerHandle>

Listens to events associated with Siri Shortcuts and notifies the listenerFunc if a Shortcuts has been executed.

| Param | Type | Description | | ------------------ | -------------------------------------------------------------------- | ----------------------------------------------- | | eventName | 'appLaunchBySiriShortcuts' | Name of the event | | listenerFunc | (shortcut: Shortcut) => void | Function to execute when listener gets notified |

Returns: Promise<PluginListenerHandle>

Since: 2.0.1


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 2.0.1


Interfaces

Options

Options to specify for the donation

| Prop | Type | Description | | ------------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | persistentIdentifier | string | 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 |