Reputation: 8108
I have created a developer account in Uber, got the client ID.
Configured the following setting in info.plist
<key>UberClientID</key>
<string>MyClientID</string>
<key>UberCallbackURI</key>
<string>MyCallBackURI</string>
Not sure what to put in UberCallbackURI but followed a tutorial in the link:
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
Also I have in appDidFinishLauncing following setting configured:
Configuration.setSandboxEnabled(true)
Just put a simple button to call uber.
let behavior = RideRequestViewRequestingBehavior(presentingViewController: self)
behavior.modalRideRequestViewController.rideRequestViewController.delegate = self
// Optional, defaults to using the user’s current location for pickup
let location = CLLocation(latitude: 37.787654, longitude: -122.402760)
let parameters = RideParametersBuilder().setPickupLocation(location).build()
let button = RideRequestButton(rideParameters: parameters, requestingBehavior: behavior)
self.view.addSubview(button)
I have also implemented following delegates in viewController :
extension ViewController : RideRequestViewControllerDelegate {
func rideRequestViewController(rideRequestViewController: RideRequestViewController, didReceiveError error: NSError) {
let errorType = RideRequestViewErrorType(rawValue: error.code) ?? .Unknown
// Handle error here
switch errorType {
case .AccessTokenMissing:
print("Access Token Missing")
break
// No AccessToken saved
case .AccessTokenExpired:
print("Access Token Expired")
break
// AccessToken expired / invalid
case .NetworkError:
print("Network error")
break
// A network connectivity error
case .NotSupported:
print("Not Supported")
break
// The attempted operation is not supported on the current device
case .Unknown:
print("Unknown")
break
// Other error
}
}
}
When I click the button the SDK sends me to loginscreen in UBER. When I sign in.
It always prints 'Access Token Missing ' which is from the delegate.
Can someone help me?
Upvotes: 1
Views: 534
Reputation: 355
You're getting that error because the login is failing. I think your problem has to do with your UberCallbackURI. On the Authorizations tab in the developer dashboard you need to set a redirect URL. You need also put this as the value for UberCallbackURI in your Info.plist
.
I would suggest using a unique url scheme that is specific to your app (as described in the link you provided)
Upvotes: 1