With the introduction of a new framework called Sirikit, last year Apple opened up new opportunities for custom iPhone app development companies to integrate Siri in their apps. In this tutorial, the developers at Inheritx will walk you through Sirikit and educate you on how you can enable your apps to interact with Siri. Market of iphone development is on a rise and iphone developers are growing at a faster rate which implies that the demand for iphone apps is high. Hire iPhone Application Programmers India from inheritx and get versatile apps for iphone, ipad, and other ios devices.
Before getting started, you need to know that the current version of sirikit does not support all kinds of applications. To find out if your app category is supported by sirikit, take a look at the list below.
Here is a comprehensive list of app domains supported by sirikit
- Payments
- Ride Booking
- Photos
- Restaurant Reservations; thought this requires additional Apple support.
- VoIP calling
- Car commands
- Messaging
To start with, you need to follow steps. Firstly an iPhone application development services provider, needs to create a new application Xcode. After that the developer needs to build a Sirikit extension. This is followed by configuring the app’s intent and finally comes Implementing the demo application.
Create a new application in Xcode
Open up Xcode and in the menu and select File > New > Project… Choose Single View Application, and press next. You can name your app whatever you want to. Save your project at a choosen place and press on create.
Enable sirikit
You need to have an Apple developer account to enable the capability of Siri.
Go to project settings and under the ‘Targets’ section, click on application name. Click on ‘capabilities’ and turn Siri on. To run your app on an actually device, one needs to have an Apple developer account, as was the case before.
If you are using the simulator for testing, you need to follow the below mentioned steps.
- Open up your simulator
- Open up Settings
- Click on Siri
- Then turn on Siri
Siri Usage description
One needs to specify why one needs to use Siri in its application. For this one needs to add a new property called ‘Privacy- Siri usage description’ in info.plist file.
Request Siri Authorization
Okay, now let’s begin to write some code. First, select the ViewController.swift file, and add the import statement to import the Intentsframework.
1 | import Intents
|
In theviewDidLoad()method, we can request for Siri authorization by inserting the following code snippet:
1
2 3 |
INPreferences.requestSiriAuthorization { (status) in
}
|
Expanding siri vocabularies
Next, one needs to expand siri vocabularies by using Invocabulary class.
Sirikit Extension
To enable your application to use Siri, build a Sirikit Entension. We’ll tell you how.
Go to Xcode Menu and select File>New>Target.
Choose Intents Extension and press next. After giving Intents Extension, target a product name and press finish.
Next, Press on the Info.plistfile under theIntents Handlergroup. Then expandNSExtension, followed byNSExtensionAttributes. Next, further expandIntentsRestrictedWhileLockedandIntentsSupported
Implementing app intent
Let us explain what is going on line by line.
func handle(Appintent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {
print(“App Intent:”, intent)
let userActivity: NSUserActivity? = nil
guard let spokenPhrase = intent.workoutName?.spokenPhrase else {
completion(INSappIntentResponse(code: .failureNoMatchingWorkout, userActivity: userActivity))
return
}
print(spokenPhrase)
completion(INSappIntentResponse(code:continueInApp, userActivity: userActivity))
}
The intent argument is later printed out.
Talking about userActivity: NSUserActivity ; it simply captures what the user wants.
The user might be viewing app content, editing a document, viewing a web page, or watching a video.
Handling app launch from Siri
This method is called whenever your app is launched to handle a SiriKit intent. It contains information about what the user is doing.
Authorization of Siri
While running the demo app in the simulator or a real device, the app will ask you for Siri Authorization. Go back to the home screen and talk to Siri.
You have completed the Siri integration with Sirikit. Businesses are staying up with the latest trends and being a Top iPhone App Development Company USA , we get many requests for integrating Siri in the applications. If you have any queries regarding the integration of Siri with Sirikit, contact us