2016-07-18 13 views
3

xcode 8はすべての新機能を備えています。私は、siriキットアプリを開発し始めました。ライド予約の概念を取る。私はすべてのステップを踏んで、コーディングパートを完成させました。残念ながら、私はシリのアプリケーションを実行することができません。私が逃したもの、あるいはさらに進めるために何をすべきかを修正してください。sirikit xcodeを使用したライディングブッキングの概念8

プロセスは続く: - UIオプションが有効と一緒に意図して

  1. を追加し、新たな目標。

  2. プロジェクト情報plistに "NSSiriUsageDescription"が追加されました。意図ハンドラボタンとマップと

  3. カスタム設計されたテントのレイアウトの情報のplistに乗る予約インテントを追加

アプリを実行中に受信エラー: -

申し訳ありませんが、名前は、間違って代。もう一度それを試すことができますか?

私を助けてくれてありがとうございます。どのような例や乗車予約の作業方法を投稿してください?

+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:あなたのIntentHandlerクラスでは、INRequestRideIntentHandlinしてクラスを拡張g、INGetRideStatusIntentHandling、INListRideOptionsIntentHandlingデリゲート。

STPE 4:あなたの乗車要求を処理するためのhandleメソッドを追加します。

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を追加して、アプリケーションを再度実行してください。