I have watched SiriKit in wwdc and read document.
https://developer.apple.com/library/prerelease/content/documentation/Intents/Conceptual/SiriIntegrationGuide/
Add SiriKit support only if your app implements one of the following
types of services:
- Audio or video calling
- Messaging Payments
- Searching photos
- Workouts
- Ride booking
I am still wondering whether I can do for other services (since my app will be for enterprise app).
My service will be very simple searching only like "Find SQ212 in myapp".
Can it be done? I afraid that sirkit can't support intent for other servies.
No, you can't. That's why it says "only if your app implements one of the following types of services".
You won't get the 'find foo
in bar
' syntax; each respective service has its own syntax - like "start a workout in MyApp" or "Book a ride to place
with MyApp". See https://developer.apple.com/sirikit/ for examples.
I would expect a workaround using the SiriKit API to result in your app being rejected if submitted to the general app store, and I would expect it to be extremely fragile if it passed App Review or didn't go through it in the first place.
I found this article on making Sirikit Extensions
that aren't default ones provided by Apple on swifting.io.
Here's the link:
https://swifting.io/blog/2016/07/18/20-sirikit-can-you-outsmart-provided-intents/
Using INVocabulary
From the Apple documentation:
The INVocabulary object lets you augment your app’s fixed vocabulary with terms that are both unique to your app and to the current user of your app. Registering custom terms provides Siri with the hints it needs to apply those terms appropriately to the corresponding intent objects. You may register only specific types of custom terms, such as the name of a contact, the name of a user’s workout, a custom tag applied to a photo, or a user-specific payment type.
public enum INVocabularyStringType : Int {
case contactName
case contactGroupName
case photoTag
case photoAlbumName
case workoutActivityName
case carProfileName
}
INMessage
Here they use INSearchForMessagesIntent to setup an index search for finding support.
struct SupportMe{
static let systems = [
INPerson(personHandle: INPersonHandle(value: "MyNotes",
type: INPersonHandleType.unknown),
nameComponents: nil,
displayName: "MyNotes",
image: nil,
contactIdentifier: "MyNotes",
customIdentifier: "MyNotes")]
static let articles = [
INMessage(identifier: "MyNotesPassword",
content: "Retrieving password in MyNotes app. To retrieve
password use 'forgot password' button that is located below
sign in button. Then type email address that your account has
been assigned to and press reset password",
dateSent: Date(),
sender: SupportMe.systems[0],
recipients: [SupportMe.systems[0]])]
}
extension IntentHandler: INSearchForMessagesIntentHandling{
func handle(searchForMessages intent: INSearchForMessagesIntent,
completion: (INSearchForMessagesIntentResponse) -> Void){
let userActivity = NSUserActivity(activityType: String(INSearchForMessagesIntent.self))
let response = INSearchForMessagesIntentResponse(code: .success,
userActivity: userActivity)
response.messages = [SupportMe.articles[0]]
completion(response)
}
}