Search code examples
iosuber-api

Uber error code in iOS SDK


I have integrated Uber iOS SDK and now working sandbox mode. Here is my ride request code.

[[UberHelper sharedInstance].ridesClient requestRideWithParameters:_rideParameters completion:^(UBSDKRide * _Nullable ride, UBSDKResponse * _Nonnull response) {NSLog(@"ERROR %@",response.error.title); NSLog(@"ERROR %@",response.error.code); NSLog(@"ERROR %ld",(long)response.statusCode);}];

But the error codes I expect was like

"errors":[
      {
         "status": 409,
         "code": "surge",
         "title": "Surge pricing is currently in effect for this product."
      }
   ].

Presently I'm getting only "status"(response.error.status) and "code" (response.error.code) and "title"(response.error.title) are "null" . I needed this "title"to display the error alert. Will this data be available in production mode?


Solution

  • Please follow this way to get the UBSDKError.

        if(response.error.errors){
    
                    UBSDKError *uberError = [response.error.errors objectAtIndex:0];
    
                    NSLog(@"title %@",uberError.title);
                    NSLog(@"code %@",uberError.code);
    }