SiriKit 对一般服务的支持
SiriKit support for general services
我在 wwdc 上看了 SiriKit 并阅读了文档。
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
我还在想我是否可以为其他服务做(因为我的应用程序将用于企业应用程序)。
我的服务会很简单,只搜索"Find SQ212 in myapp"。
可以吗?恐怕 sirkit 不能支持其他服务的意图。
不,你不能。这就是为什么它说“仅当 您的应用实现了以下服务类型之一”。
您不会得到 'find foo
in bar
' 语法;每个服务都有自己的语法 - 如 "start a workout in MyApp" 或 "Book a ride to place
with MyApp"。有关示例,请参阅 https://developer.apple.com/sirikit/。
我希望使用 SiriKit API 的解决方法会导致您的应用程序在提交到一般应用程序商店时被拒绝,我希望它非常 如果它通过了 App Review 或者一开始就没有通过它,那就很脆弱。
我发现 this article 制作不是 Apple 在 swifting.io 上提供的默认扩展的 Sirikit 扩展。
使用 INVocabulary
来自 Apple 文档:
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
他们在这里使用 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)
}
}
我在 wwdc 上看了 SiriKit 并阅读了文档。
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
我还在想我是否可以为其他服务做(因为我的应用程序将用于企业应用程序)。
我的服务会很简单,只搜索"Find SQ212 in myapp"。
可以吗?恐怕 sirkit 不能支持其他服务的意图。
不,你不能。这就是为什么它说“仅当 您的应用实现了以下服务类型之一”。
您不会得到 'find foo
in bar
' 语法;每个服务都有自己的语法 - 如 "start a workout in MyApp" 或 "Book a ride to place
with MyApp"。有关示例,请参阅 https://developer.apple.com/sirikit/。
我希望使用 SiriKit API 的解决方法会导致您的应用程序在提交到一般应用程序商店时被拒绝,我希望它非常 如果它通过了 App Review 或者一开始就没有通过它,那就很脆弱。
我发现 this article 制作不是 Apple 在 swifting.io 上提供的默认扩展的 Sirikit 扩展。
使用 INVocabulary
来自 Apple 文档:
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
他们在这里使用 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)
}
}