bartwesselink / cordova-plugin-siri-shortcuts

Adds support for Siri Shortcuts to Cordova, requires XCode 10 and iOS >= 12.0
30 stars 26 forks source link

method to retrieve all shortcuts created by the Cordova app #10

Open beaudry12087 opened 5 years ago

beaudry12087 commented 5 years ago

There is an API to donate, present, and remove shortcuts but It will be pretty useful to have a method to retrieve all the shortcuts created by the Cordova app. This will be very useful as it will allow solving an issue like this one https://github.com/bartwesselink/cordova-plugin-siri-shortcuts/issues/9 without the need to change the existing APIs.

levieu commented 5 years ago

Hi, in my fork i have add un api to retrieve all shortcuts. The api is getAll and the success callback returns an array of key-value object containing: { persistentIdentifier: string; invocationPhrase: string; }. In ionic app you must extends the SiriShortcuts plugin and add the method getAll. Moreover, you must add this class in list of providers in the app.module file. Below an example: import { Injectable } from '@angular/core'; import { SiriShortcuts } from '@ionic-native/siri-shortcuts'; import { Cordova } from '@ionic-native/core'; export interface SiriShortcutSaved { persistentIdentifier: string; invocationPhrase: string; } @Injectable() export class SiriShortcutsExtends extends SiriShortcuts { /** * Get all shortcut saved * @return Promise<SiriShortcutSaved[]> */ @Cordova() getAll(): Promise<SiriShortcutSaved[]> { return; } }

beaudry12087 commented 5 years ago

@levieu Thank you. This is amazing