2016-07-18 1 views
3

xcode 8은 모든 새로운 기능을 갖추고 있습니다. 내가 siri 키트 애플 리케이션에 대한 작업을 시작했다. 라이드 예약 개념을 복용. 나는 모든 단계를 따르고 코딩 부분을 완성했다. 불행히도 저는 siri에서 app을 실행할 수 없습니다. 제가 놓친 부분이나 앞으로 나아 가기 위해해야 ​​할 일을 수정하십시오.sirikit xcode를 사용하는 라이드 북 개념 8

프로세스는 다음 : - UI 옵션이 설정과 함께 의도와

  1. 추가 된 새로운 목표.

  2. 프로젝트 정보 plist에 "NSSiriUsageDescription"이 추가되었습니다. 의도 핸들러 버튼과지도

  3. 사용자 정의 설계 의도 레이아웃의 정보 PLIST에 타고 예약 텐트를 추가

  4. . 응용 프로그램을 실행하는 동안 수신

오류 : -

죄송합니다, 이름이 잘못 간 일도. 다시해볼 수 있니?

나를 도와 주셔서 미리 감사드립니다. 어떤 예를 게시 하시거나 승차 예약을하는 방법을 알려주십시오.

+0

오류의 스크린 샷을 업로드 할 수 있습니까? – Dhawal

+0

현재 같은 문제가 있습니다 ... – MCKapur

답변

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 1

단계) :

<?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 단계 : INRequestRideIntentHandlin하여 클래스를 확장하여 IntentHandler 클래스에서 g, INGetRideStatusIntentHandling, INListRideOptionsIntentHandling 대리자.

STPE 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 단계 : 모두 의도 확장에의 Info.plist에 NSExtension에 INRequestRideIntent를 추가합니다.

6 단계 : 먼저 기기에 & 앱을 실행하고 기기에서 확장 프로그램을 실행합니다.

설명하는 것처럼 오류가 발생하면 프로젝트에 CoreLocation.framework를 추가하고 앱을 다시 실행하십시오.

관련 문제