Интегрировать Uber с моим приложением

Я пытался сделать кнопку uber, когда вы нажимаете кнопку, все, что я хочу, это открыть приложение uber с местом высадки.

Я уже читал там api (https://github.com/uber/rides-ios-sdk) и я сделал именно то, что он говорит, но когда я нажимаю кнопку uber, все, что он делает, это открывает приложение uber без указания местоположения.

Это мой код, подскажите где

CLLocation *loc = [[CLLocation alloc]initWithLatitude:26.410640 longitude:50.099568];

UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude: self.locationManager.location.coordinate.latitude longitude: self.locationManager.location.coordinate.longitude];
CLLocation *dropoffLocation = [[CLLocation alloc] initWithLatitude: loc.coordinate.latitude longitude: loc.coordinate.longitude];
__block UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
builder = [builder setPickupLocation: pickupLocation];
builder = [builder setDropoffLocation: dropoffLocation];
[ridesClient fetchCheapestProductWithPickupLocation: dropoffLocation completion:^(UBSDKUberProduct* _Nullable product, UBSDKResponse* _Nullable response) {
    if (product) {
        builder = [builder setProductID: product.productID];
        button.rideParameters = [builder build];
        [button loadRideInformation];
    }
}];

[self.view addSubview:button];

person Abdullah Amer    schedule 07.08.2016    source источник
comment
Это может быть не причиной, но похоже, что вы перепутали dropoffLocation с pickupLocation @ fetchCheapestProductWithPickupLocation. Оценки времени и цены на кнопке должны быть неверными из-за путаницы в местоположении.   -  person Alexander Graebe    schedule 07.08.2016
comment
Нет, сэр, это каталог с сайта разработчика.   -  person Abdullah Amer    schedule 08.08.2016


Ответы (1)


Технически RideRequestButton использует глубокие ссылки для отправки параметров в приложение Uber. Как указано в на самой кнопке раздела README , вы должны указать псевдоним или отформатированный адрес для этого места. В противном случае пин не будет отображаться.

Я обновил ваш код, чтобы добиться этого. Не могли бы вы попробовать и дайте мне знать, если это сработает?

CLLocation *dropoffLocation = [[CLLocation alloc]initWithLatitude:26.410640 longitude:50.099568];

UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude: self.locationManager.location.coordinate.latitude longitude: self.locationManager.location.coordinate.longitude];
__block UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
builder = [builder setPickupLocation: pickupLocation];
[[builder setPickupLocation:pickupLocation] 
builder = [builder setDropoffLocation: dropoffLocation nickname: @"Somewhere" address:@"123 Fake St."];
[ridesClient fetchCheapestProductWithPickupLocation: pickupLocation completion:^(UBSDKUberProduct* _Nullable product, UBSDKResponse* _Nullable response) {
    if (product) {
        builder = [builder setProductID: product.productID];
        button.rideParameters = [builder build];
        [button loadRideInformation];
    }
}];

[self.view addSubview:button];
person Alexander Graebe    schedule 07.08.2016
comment
Не могли бы вы отметить эту тему как решенную, если ваша проблема решена? Спасибо! - person Alexander Graebe; 08.08.2016
comment
Это не решило мою проблему, приложение Uber по-прежнему открыто без пункта выдачи. - person Abdullah Amer; 08.08.2016
comment
Вы уверены, что fetchCheapestProductWithPickupLocation выполнен успешно? Если это не так, то вы никогда не устанавливаете параметры езды. Я бы предложил установить параметры поездки перед выполнением этого вызова, а затем обновить их, чтобы включить идентификатор продукта, когда он вернется. - person John Brophy; 08.08.2016