Add Siri Shortcut in iOS App using Swift 4

Siri Shortcut in iOS App

In iOS  12 Apple provides the capability to add the Siri within the App where you can execute or perform a task by informing to Siri. Here we are taking the example of showing the cart data using

Siri.

Cart Data means : It is viewcontroller class which show the cart item .

Siri Shortcut is basically a voice command where you have to registered first after that when the siri detect the same voice command then it will automatically execute your task.

For this Follows this Steps:

1: Create a Unique ID for Siri Shortcut :

Here we have taken the bundle ID of Application :

2: Create a class for Siri :

Here   we have created the CartShortcut Class , it will return the Siri Shortcut Object.

3: Now Go to Class where you have to give this feature , I have given this facility in my Setting class of App.

a: take UIButton  , name as Siri Shortcut or you can add the image.

b: take a UITableView where you can show the previous & current phrase of Siri Shortcut . you can edit or delete this phrase as well.

c:Write the Function of this class.

Note: Here we have taken the delegate of Siri Shortcut for Add & edit case

d: First we will check weather previous phrases are available or not , if available then show to user so they can edit or delete this.

Note: It will show all the available phrases on TableView.

here you can see, on click of any Cell we are calling edit shortcut class so that it will help to edit or delete this phrase.

List of available phrase:

 

 

On Click on that:

 

Now we are aware about the available phrase edit &  delete .

 

4: Now its time to Add the siri shortcut functionality.

create a Outlet of Button then write this:

Note: Now you can add the new siri shortcut in your App.

 

5: Lets go to handle this action.

when you add all the shortcut in your App then we have to handle this ,by which we can perform desired work for this.

a: Go to Appdelegate.swift class & write this.

it will match with siri shortcut ID that you have given on creation .

here We have managed through Notification Center so it will inform when it will be execute.

 

If you need any kind of help regarding Siri shortcut lets comment to Us .

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close