2016-07-18 9 views
3

Wie wir wissen, dass xcode 8 mit allen neuen Funktionen integriert ist. Ich fing an, an den Siri-Kit-Apps zu arbeiten. Konzept der Fahrtbuchung nehmen. Ich folgte allen Schritten und vervollständigte den Codierabschnitt. Leider kann ich keine App in Siri ausführen. Bitte korrigiere mich, was ich vermisse oder was ich tun sollte, um weiter zu machen.RideBooking Konzept mit sirikit xcode 8

Prozess verfolgt: -

  1. Added neue Ziele mit Absichten zusammen mit UI-Option aktiviert.

  2. Hinzugefügt "NSSiriUsageDescription" in der Projektinfo plist.

  3. Hinzufügen Fahrt Buchung Intents in der Info-plist Absichts Handler

  4. Kundenspezifische Intent Layout mit den Tasten und Karte. Empfangen

Fehler bei der Anwendung ausgeführt wird: -

Sorry, Name, Somethings schief gegangen. kannst du das nochmal versuchen?

Vielen Dank im Voraus für die Hilfe. Bitte posten Sie ein beliebiges Beispiel oder wie arbeiten Sie mit Ride Booking?

+0

Können Sie einen Screenshot des Fehlers hochladen? – Dhawal

+0

Das gleiche Problem im Moment ... – MCKapur

Antwort

1

Ich mache auch das gleiche wie Sie tun. Aber ich meine Probleme gelöst und hier habe ich meinen Code teilen:

Schritt 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 
     } 
    } 

Schritt 2: Erstellen Sie eine plist-Datei, die alle speichert Ihre Absichten und Vokabular in Hauptprojekt (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> 

Schritt 3: In Ihrer IntentHandler Klasse, die Klasse erweitern, indem INRequestRideIntentHandlin g, INGetRideStatusIntentHandling, INListRideOptionsIntentHandling Delegaten.

STPE 4: Hinzufügen Griff Methode für Ihre Fahrt Anfrage Handhabung:

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) { 
} 

Schritt 5: Hinzufügen INRequestRideIntent in NSExtension in Info.plist in beiden Intent-Erweiterungen.

Schritt 6: Erstellen Sie zunächst & App in Ihrem Gerät und führen Sie Ihre Erweiterung in Ihrem Gerät.

Wenn ein Fehler zurückgegeben wird, den Sie beschreiben, fügen Sie einfach CoreLocation.framework in Ihrem Projekt hinzu und führen Sie die App erneut aus.