Skip to main content

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?

Don't waste precious time on plugin issues.

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.

Installation#

$ npm install cordova-plugin-siri-shortcuts
$ npm install @ionic-native/siri-shortcuts
$ ionic cap sync

Supported Platforms#

  • iOS

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

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