我看过SiriKit在wwdc和阅读文件。
只有当应用程序实现下列服务类型之一时,才添加SiriKit支持:
我仍然在想,我是否可以为其他服务(因为我的应用程序将为企业应用程序)。
我的服务将是非常简单的搜索,只像“在我的应用中找到SQ212”。
能办到吗?我担心sirkit不能支持其他服务器的意图。
发布于 2016-06-20 02:59:15
不,你不能。这就是为什么它说“只有当你的应用程序实现以下服务类型之一时,才会出现”。
您不会得到'find foo in bar‘语法;每个服务都有自己的语法--比如“在MyApp中开始锻炼”或“用MyApp预订到place的旅程”。有关示例,请参见https://developer.apple.com/sirikit/。
如果将应用程序提交给普通应用程序商店,我预计使用API的解决方案会导致应用程序被拒绝,如果它通过了API,或者一开始就没有经过它,我会认为它是非常脆弱的。
发布于 2016-09-26 21:31:33
我发现这篇文章是在制作Sirikit扩展时发现的,这些扩展不是苹果在swifting.io上提供的默认扩展。
使用 INVocabulary
来自苹果公司的文档:
INVocabulary对象允许您使用对应用程序和应用程序的当前用户都独特的术语来扩展应用程序的固定词汇表。注册自定义术语为Siri提供了适当地将这些术语应用于相应意图对象所需的提示。您可以只注册特定类型的自定义术语,例如联系人的名称、用户的锻炼名称、应用于照片的自定义标记或特定于用户的支付类型。
public enum INVocabularyStringType : Int {
case contactName
case contactGroupName
case photoTag
case photoAlbumName
case workoutActivityName
case carProfileName
}INMessage
在这里,他们使用INSearchForMessagesIntent设置索引搜索以查找支持。
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)
}
}https://stackoverflow.com/questions/37914025
复制相似问题