- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
众所周知,xcode 8 融入了所有新功能。我开始开发 Siri Kit 应用程序。采用乘车预订的概念。我遵循了所有步骤并完成了编码部分。不幸的是我无法在 Siri 中运行应用程序。请纠正我遗漏的内容或我应该做哪些更改才能进一步进行。
遵循的流程:-
添加了带有意图的新目标并启用了 UI 选项。
在项目信息 plist 中添加了“NSSiriUsageDescription ”。
在意图处理程序的信息 plist 中添加乘车预订意图
带有按钮和 map 的自定义设计意图布局。
运行应用程序时接收错误:-
抱歉,名字,出了点问题。你能再试一次吗?
预先感谢您对我的帮助。请发布任何示例或如何使用乘车预订?
最佳答案
我也在做和你一样的事情。但我解决了我的问题,在这里我分享我的代码:
第 1 步:AppDelegate:
INPreferences.requestSiriAuthorization {
switch $0 {
case .authorized:
print("authorized")
break
case .notDetermined:
print("notDetermined")
break
case .restricted:
print("restricted")
break
case .denied:
print("denied")
break
}
}
第 2 步:创建一个 plist
文件,该文件将在主项目 (AppIntentVocabulary.plist) 中存储所有意图和词汇:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ParameterVocabularies</key>
<array>
<dict>
<key>ParameterNames</key>
<array>
<string>INRequestRideIntent.SlideToOpen</string>
</array>
<key>ParameterVocabulary</key>
<array>
<dict>
<key>VocabularyItemIdentifier</key>
<string>slide_to_open</string>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemExamples</key>
<array>
<string>Book ride in MyApp</string>
</array>
</dict>
</array>
</dict>
</array>
</dict>
</array>
<key>IntentPhrases</key>
<array>
<dict>
<key>IntentName</key>
<string>INRequestRideIntent</string>
<key>IntentExamples</key>
<array>
<string>Book smart parking</string>
<string>Get ETA Way</string>
<string>Go Online in Way</string>
<string>Book ride in Way</string>
<string>Book table in way</string>
</array>
</dict>
</array>
第 3 步:在 IntentHandler 类中,通过 INRequestRideIntentHandling、INGetRideStatusIntentHandling、INListRideOptionsIntentHandling 委托(delegate)扩展您的类。
步骤 4:添加处理方法来处理您的乘车请求:
func handle(requestRide intent: INRequestRideIntent, completion: @escaping (INRequestRideIntentResponse) -> Void) {
}
func handle(getRideStatus intent: INGetRideStatusIntent, completion: @escaping (INGetRideStatusIntentResponse) -> Void) {
}
func handle(listRideOptions intent: INListRideOptionsIntent, completion: @escaping (INListRideOptionsIntentResponse) -> Void) {
let response = INListRideOptionsIntentResponse(code: .success, userActivity: nil)
let smallCarOption = INRideOption(name: "Small Car", estimatedPickupDate: Date(timeIntervalSinceNow: 3 * 60)) // You must provide a name and estimated pickup date.
smallCarOption.priceRange = INPriceRange(firstPrice: NSDecimalNumber(string: "5.60") , secondPrice: NSDecimalNumber(string: "10.78"), currencyCode: "USD") // There are different ways to define a price range and depending on which initializer you use, Maps may change the formatting of the price.
smallCarOption.disclaimerMessage = "This is a very small car, tall passengers may not fit." // A message that is specific to this ride option.
smallCarOption.availablePartySizeOptions = [
INRidePartySizeOption(partySizeRange: NSRange(location: 0, length: 1), sizeDescription: "One person", priceRange: nil),
INRidePartySizeOption(partySizeRange: NSRange(location: 0, length: 2), sizeDescription: "Two people", priceRange: INPriceRange(firstPrice: NSDecimalNumber(string: "6.60") , secondPrice: NSDecimalNumber(string: "11.78"), currencyCode: "USD"))
]
smallCarOption.availablePartySizeOptionsSelectionPrompt = "Choose a party size"
smallCarOption.specialPricing = "High demand. 50% extra will be added to your fare."
smallCarOption.specialPricingBadgeImage = INImage(named: "specialPricingBadge")
let base = INRideFareLineItem(title: "Base fare", price: NSDecimalNumber(string: "4.76"), currencyCode: "USD" )!
let airport = INRideFareLineItem(title: "Airport fee", price: NSDecimalNumber(string: "3.00"), currencyCode: "USD" )!
let discount = INRideFareLineItem(title: "Promo code (3fs8sdx)", price: NSDecimalNumber(string: "-4.00"), currencyCode: "USD" )!
smallCarOption.fareLineItems = [ base, airport, discount ]
smallCarOption.userActivityForBookingInApplication = NSUserActivity(activityType: "bookInApp");
response.rideOptions = [ smallCarOption ]
let paymentMethod = INPaymentMethod(type: .credit, name: "Visa Platinum", identificationHint: "•••• •••• •••• 1234", icon: INImage(named: "creditCardImage"))
let applePay = INPaymentMethod.applePay() // If you support Pay and the user has an Pay payment method set in your parent app
response.paymentMethods = [ paymentMethod, applePay ]
response.expirationDate = Date(timeIntervalSinceNow: 5 * 60)
}
func confirm(requestRide intent: INRequestRideIntent, completion: @escaping (INRequestRideIntentResponse) -> Void) {
let rideOption = INRideOption(name: "Small car", estimatedPickupDate: Date(timeIntervalSinceNow: 5 * 60))
let rideStatus = INRideStatus()
rideStatus.rideOption = rideOption
rideStatus.estimatedPickupDate = Date(timeIntervalSinceNow: 5 * 60)
rideStatus.rideIdentifier = NSUUID().uuidString
let response = INRequestRideIntentResponse(code: .success, userActivity: nil)
response.rideStatus = rideStatus
completion(response)
}
func startSendingUpdates(forGetRideStatus intent: INGetRideStatusIntent, to observer: INGetRideStatusIntentResponseObserver) {
}
func stopSendingUpdates(forGetRideStatus intent: INGetRideStatusIntent) {
}
第 5 步:在两个 Intent 扩展中的 Info.plist 中的 NSExtension 中添加 INRequestRideIntent。
第 6 步:首先在您的设备中构建并运行应用程序,然后在设备中运行您的扩展程序。
如果它返回像您所描述的错误,则只需在您的项目中添加 CoreLocation.framework 并再次运行应用程序。
关于ios - 使用 Sirikit xcode 8 的 RideBooking 概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38430176/
众所周知,xcode 8 融入了所有新功能。我开始开发 Siri Kit 应用程序。采用乘车预订的概念。我遵循了所有步骤并完成了编码部分。不幸的是我无法在 Siri 中运行应用程序。请纠正我遗漏的内容
我是一名优秀的程序员,十分优秀!