2017-05-31 22 views
0

我在iOS應用程序中使用Uber-SDK。在過去的幾天裏,我可以通過ridesClient.fetchCheapestProduct()獲得最便宜的產品。但今天,該函數總是返回一個nil值。Rides-ios-sdk - 獲取最便宜的產品

這是服務器還是SDK的問題?請幫我解決這個問題。 (我在越南和我client_id仍然能正常爲Android)

這是我的代碼:

let ridesClient = RidesClient() 
let button = RideRequestButton() 

override func viewDidLoad() { 
    super.viewDidLoad() 

    let pickupLocation = CLLocation(latitude: 37.775159, longitude: -122.417907) 
    let dropoffLocation = CLLocation(latitude: 37.6213129, longitude: -122.3789554) 

    //make sure that the pickupLocation and dropoffLocation is set in the Deeplink 
    var builder = RideParametersBuilder() 
     .setPickupLocation(pickupLocation) 
     // nickname or address is required to properly display destination on the Uber App 
     .setDropoffLocation(dropoffLocation, nickname: "San Francisco International Airport") 

    // use the same pickupLocation to get the estimate 
    ridesClient.fetchCheapestProduct(pickupLocation: pickupLocation, completion: { product, response in 
     if let productID = product?.productID { //check if the productID exists 
      builder = builder.setProductID(productID) 
      self.button.rideParameters = builder.build() 

      // show estimate in the button 
      self.button.loadRideInformation() 
     } 
    }) 


    // center the button (optional) 
    button.center = view.center 

    //put the button in the view 
    view.addSubview(button) 
} 

回答

1

確保您設置一個server token in your Info.plist。這允許RidesClient()進行價格估算API調用。

將此片段複製到您的Info.plist(右鍵單擊並選擇Open As> Source Code),並將YOUR_SERVER_TOKEN替換爲儀表板中的Server Token(確保使用與您的客戶端ID相對應的服務器令牌)。

<key>UberServerToken</key> 
<string>YOUR_SERVER_TOKEN</string> 
相關問題