【问题标题】:Google Places Deprecation on iOS在 iOS 上弃用 Google Places
【发布时间】:2019-09-24 11:57:36
【问题描述】:

目前在 iOS 上,我们直接使用 URL:

  let parameters = @{
    @"input": query,
    @"key": @"MY_API_KEY",
    @"language": "en",
    @"components": @"country:ca",
  };

  let url = @"https://maps.googleapis.com/maps/api/place/autocomplete/json";

  let request = [self createRequest:url parameters: parameters];

  let task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {

    if ([responseObject[@"status"] isEqualToString:@"OK"]) {
      let predictions = (NSArray<NSDictionary *> *)responseObject[@"predictions"];

      //parse predictions..
      completion(predictions, nil);
    }

    //..handle error..
  }];

我们收到了一封关于弃用 Google Places API 的电子邮件:

我们写信提醒您,以前版本的 Places SDK Google Maps Platform 已于 2019 年 1 月 29 日弃用,并且 将于 2019 年 7 月 29 日关闭。

在电子邮件中包含指向:https://developers.google.com/places/ios-sdk/client-migration的链接

我的问题是,我真的必须导入整个 iOS Maps-SDK 和 iOS Places-SDK 才能让自动完成建议正常工作吗?

我发出请求的代码要少得多,而且我不必导入 70mb+ 的 SDK。..

这个网址“https://maps.googleapis.com/maps/api/place/autocomplete/json”也会被弃用吗?还是只是 SDK?

【问题讨论】:

  • 您在问题中发布的 Objective-C 和 Swift 语法的奇怪组合是什么?
  • @rmaddy;它完全是 Objective-C :D 我使用了这里定义的宏:pastebin.com/8DM5bksR。在 Xcode 8 中,Apple 通过 __auto_type 将 C++ 的 auto 类型添加到 Objective-C,它在 WWDC 中,所以我使用它,因为我的代码库的其余部分都使用它。
  • 我说这很酷。它确实使两种语言之间的转换更容易。

标签: ios objective-c google-maps google-places-api


【解决方案1】:

您在问题中提到的 URI https://maps.googleapis.com/maps/api/place/autocomplete/json 不属于 iOS 版 Places SDK 的一部分。此 URI 属于 Places API Web 服务,相应的文档可以在

找到

https://developers.google.com/places/web-service/autocomplete.

Places API 网络服务未被弃用,因此如果您的代码直接调用 https 网络服务,您就可以了。没什么好担心的。

此弃用仅影响使用 Places SDK for iOS 方法的用户,而您的情况并非如此。

我希望这能澄清你的疑问。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-08
    • 1970-01-01
    • 2017-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    相关资源
    最近更新 更多