iOS应用程序受到本地搜索的限制 [英] iOS app getting throttled from local searches

查看:152
本文介绍了iOS应用程序受到本地搜索的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个搜索地址的应用中实现自动完成(每个新角色添加一个搜索),并且我一直收到 MKErrorDomain错误3 ,这是 MKErrorLoadingThrottled 。根据 Apple dev ,此错误发生在

I am implementing autocomplete (one search per new character added) in an app that searches for addresses, and I keep getting MKErrorDomain error 3, which is MKErrorLoadingThrottled. This error, according to Apple dev, occurs when


由于数据限制生效,因此未加载数据。如果应用程序在短时间内频繁请求数据,则会发生
错误。

The data was not loaded because data throttling is in effect. This error can occur if an app makes frequent requests for data over a short period of time.

我确切地知道有多少请求正在进行,一个用于搜索查询中的每个新charachter(就像你希望自动完成工作一样)。当然,我是一个快速的人,但只有10或15个请求后能够达到极限似乎是荒谬的。看看以下两个来源参考,我不明白为什么我会受到限制。

I know exactly how many requests are being made, one for each new charachter in the search query (just like you would expect autocomplete to work). Sure, I am a fast typer, but being able to hit the limit after just 10 or 15 requests seems absurd. Looking at the following two source references, I do not understand why I keep getting throttled.

根据 Apple dev


没有每个应用程序或开发者ID的请求限制,因此编写良好的
应用程序正常运行应该没有遇到任何问题。但是,
限制可能发生在写得不好的应用程序中,该应用程序会产生极大的
大量请求。

There are no request limits per app or developer ID, so well-written apps that operate correctly should experience no problems. However, throttling may occur in a poorly written app that creates an extremely large number of requests.

詹姆斯·霍华德在WWDC上说:


我想谈的另一件事就是这个
API的使用限制。
所以,我很高兴地宣布没有应用程序或开发人员
标识符的广泛使用限制。
所以,如果你有一个拥有大量用户的应用程序并且你想要做很多
的请求,那就没关系。

And the other thing I want to talk about is the Usage Limits on this API. So, I'm happy to announce that there's no application or developer identifier wide usage limits. So, if you have a app that has a lot of users and you want to do a lot of requests, that's fine.

它我会工作。

我们所拥有的限制实际上只是针对有缺陷的应用程序的
防御的第一线。
所以,如果你在
无限循环中放置路线请求或本地搜索请求,你就会遇到一个错误,最终你会得到
限制。

And the throttling that we do have is really just a first line of defense against buggy apps. So, if you put directions requests or local search requests in an infinite loop, you've got a bug, eventually you're going to get throttled.

但是如果你做了一些合理的事情,你会说哦,我只会按照用户输入做
指示,你知道你可以做一些
那些是因为我们向他们展示了这个例子。

就像我们做了两个方向请求以响应一个用户输入,
没关系。
但是,你知道如果你每次用户点击
屏幕时你做的是10,000,那么你将受到限制。
但是,只要保持合理,你就没事了。

Like we did two directions request in response to one user input, that's fine. But, you know if you're doing 10,000 every time the user taps on the screen, then you're going to get throttled. But, just keep it reasonable and you'll be fine.

为什么会发生这种情况?

Any ideas to why this is happening??

推荐答案

自动完成需要特殊的API。 MapKit不提供这样的界面。向普通搜索API发出数十个请求会导致巨大的负担。

Autocompletion requires a special APIs. MapKit doesn't offer such an interface. Just firing off dozens of requests to the normal search API causes a tremendous load.

您基本上有两种选择:


  1. 使用Google地方信息。他们有专门的 Places Autocompletion API 。在 GitHub 上甚至还有一个完整的iOS库。

  1. Go with Google Places. They have a dedicated Places Autocompletion API. There is even a complete library for iOS on GitHub.

减少请求数量,例如通过仅在用户暂停键入300ms并且仅在没有先前请求未完成时发送请求。但是,仍然无法保证Apple不会限制您的请求。

Reduce the number of requests, e.g. by only sending a request if the user has paused typing for 300ms and only if no earlier request is outstanding. But that's still no guarantee that Apple won't throttle your requests.

这篇关于iOS应用程序受到本地搜索的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆