【问题标题】:Integrate Uber with my app将优步与我的应用程序集成
【发布时间】:2016-12-13 09:52:19
【问题描述】:

当您单击按钮时,我尝试制作 uber 按钮,我想要的只是打开带有 dropoff Location 的 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];

【问题讨论】:

  • 这可能不是原因,但看起来您将 dropoffLocation 与pickupLocation @fetchCheapestProductWithPickupLocation 混淆了。由于位置混淆,按钮上的时间和价格估计值应该不正确。
  • 不,先生,来自开发者网站的目录

标签: ios uber-api


【解决方案1】:

从技术上讲,RideRequestButton 使用深层链接将参数发送到优步应用程序。如very button of the README section 所述,您必须为该位置提供昵称或格式化地址。否则,图钉将不会显示。

我更新了您的代码以实现这一点。你能试一试,让我知道它是否有效?

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];

【讨论】:

  • 如果您的问题已解决,能否将此主题标记为已解决?谢谢!
  • 它没有解决我的问题,Uber 应用程序仍然打开,没有下车地点。
  • 您确定 fetchCheapestProductWithPickupLocation 成功了吗?如果不是,那么您永远不会设置骑行参数。我建议在调用之前设置乘车参数,然后在返回时更新它们以包含产品 ID。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-07
  • 2015-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-23
相关资源
最近更新 更多