Search docs/

Siri Shortcuts

This plugin only works when your app is built with XCode 10. Shortcuts will only appear on iOS-versions >= 12.0

This plugin enables the use of Siri shortcuts in Cordova. Siri Shortcuts enable the user to perform certain actions by adding them to Siri. After you have donated a shortcut to Siri, it will appear in the settings menu, after which the user is able to add the action. You can check whether the user launched your app through a shortcut by calling getActivatedShortcut() when the app is resumed. It will return null if it has not been launched by Siri, and if it did, it will return an object with SiriShortcut properties.

https://github.com/bartwesselink/cordova-plugin-siri-shortcuts

Stuck on a Cordova issue?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Contact Us Today!

Installation

ionic cordova plugin add cordova-plugin-siri-shortcutsnpm install @ionic-native/siri-shortcuts
Ionic Native Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us

Supported Platforms

  • iOS

Usage

import { SiriShortcuts } from '@ionic-native/siri-shortcuts/ngx';


constructor(private siriShortcuts: SiriShortcuts) { }

...


this.siriShortcuts.donate({
      persistentIdentifier: 'open-my-app',
      title: 'Open my app',
      suggestedInvocationPhrase: 'Open my app',
      userInfo: { username: 'username' },
      isEligibleForSearch: true,
      isEligibleForPrediction: true,
  })
  .then(() => console.log('Shortcut donated.'))
  .catch((error: any) => console.error(error));

this.siriShortcuts.present({
      persistentIdentifier: 'open-my-app',
      title: 'Open my app',
      suggestedInvocationPhrase: 'Open my app',
      userInfo: { username: 'username' },
  })
  .then(() => console.log('Shortcut added.'))
  .catch((error: any) => console.error(error));

this.siriShortcuts.remove('open-my-app')
  .then(() => console.log('Shortcut removed.'))
  .catch((error: any) => console.error(error));

this.siriShortcuts.removeAll()
  .then(() => console.log('All shortcuts removed removed.'))
  .catch((error: any) => console.error(error));

this.siriShortcuts.getActivatedShortcut()
  .then((data: SiriShortcut|null) => console.log(data))
  .catch((error: any) => console.error(error));