SiriKit支持一般服务

我在wwdc中看过SiriKit并阅读过文档。

https://developer.apple.com/library/prerelease/content/documentation/Intents/Conceptual/SiriIntegrationGuide/

仅当您的应用程序实现以下types的服务时才添加SiriKit支持:

  • audio或video通话
  • 消息付款
  • search照片
  • 锻炼
  • 乘坐预订

我仍然想知道我是否可以为其他服务做(因为我的应用程序将为企业应用程序)。

我的服务将非常简单,只search“在myapp中查找SQ212”。

可以这样做吗? 我害怕sirkit不能支持其他服务的意图。

不,你不能。 这就是为什么它说“ 只有当你的应用程序实现以下types的服务之一”。

你不会得到'findfoo bar '语法; 每个服务都有自己的语法,比如“在MyApp中开始锻炼”或者“预订MyApp”。 有关示例,请参阅https://developer.apple.com/sirikit/

我期望使用SiriKit API的解决方法会导致您的应用在被提交到一般app store时被拒绝,并且如果它通过App Review或者没有经过它,那么我认为它会非常脆弱。

我发现这篇文章是关于在swifting.io上制作不是Apple提供的默认版本的Sirikit Extensions

这是链接:

https://swifting.io/blog/2016/07/18/20-sirikit-can-you-outsmart-provided-intents/

使用INVocabulary

从Apple文档:

INVocabulary对象使您可以使用对应用程序和应用程序的当前用户都是唯一的术语来扩充应用程序的固定词汇表。 注册自定义条款为Siri提供了将这些条款适当应用于相应的意图对象所需的提示。 您可能只注册特定types的自定义术语,如联系人姓名,用户锻炼名称,应用于照片的自定义标签或用户特定的付款types。

 public enum INVocabularyStringType : Int { case contactName case contactGroupName case photoTag case photoAlbumName case workoutActivityName case carProfileName } 

INMessage

在这里,他们使用INSearchForMessagesIntent来设置索引search来寻找支持。

 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) } }