Check Mobile App
Read now
Start a Project

Add Siri Shortcut in iOS App using Swift 4

Save

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 .

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Vishnu. KV
    Can I add Siri shortcut directly without showing Add to Siri button in INUIAddVoiceShortcutViewController ? My requirement is to add Siri shortcut automatically via code (backend) and just inform user that Siri shortcut is already added for this feature. Please help here.
    • siddhant kumar (Moderator)
      Hello,
      You can open INUIAddVoiceShortcutViewController without adding Add To Siri button but adding the shortcut need to be done via addVoiceShortcutViewController(:didFinish:) method manually. You can open the Siri Shortcut controller automatically but its delegate needs to be called manually via the user.
  • css.php

    The support is fast and do everything in their power to make it perfect. If you need customization it's also done right away. I had massive research to select Mobikul and now I'm sure it was the right one.

    Igor Souza

    Igor Souza

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home