iOS应用程序从本地搜索中获得限制

iOS应用程序从本地搜索中获得限制,第1张

概述我在一个搜索地址的应用程序中实现自动完成(每个新添加的字符一个搜索),并且我继续收到MKErrorDomain错误3,这是MKErrorLoadingThrottled.这个错误,根据 Apple dev,发生时 The data was not loaded because data throttling is in effect. This error can occur if an app 我在一个搜索地址的应用程序中实现自动完成(每个新添加的字符一个搜索),并且我继续收到MKErrorDomain错误3,这是MKErrorLoadingThrottled.这个错误,根据 Apple dev,发生时

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.

我确切地知道正在进行多少请求,一个用于搜索查询中的每个新字符(就像您希望自动完成工作一样).当然,我是一个快速的老板,但只要10或15个请求似乎是荒谬的,可以达到极限.看看以下两个来源引用,我不明白为什么我不断被扼制.

根据Apple dev:

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.

和詹姆斯·霍华德said at a WWDC:

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.

It’ll work.

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.

But if you do something reasonable,you say oh,I’m going to just do
directions in response to user input and you kNow you can do a few of
those because we showed them that example.

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.

任何想法为什么这是发生?

解决方法 自动完成需要一个特殊的API. MapKit不提供这样的界面.只需开启数十个对正常搜索API的请求就会产生巨大的负担.

你基本上有两个选择:

>使用Google商家信息.他们有一个专门的Places Autocompletion API.甚至有一个完整的图书馆为iOS在GitHub.>减少请求的数量,例如只有当用户已经暂停输入300ms并且只有没有先前的请求未完成时才发送请求.但是,这并不能保证苹果不会限制您的请求.

总结

以上是内存溢出为你收集整理的iOS应用程序从本地搜索中获得限制全部内容,希望文章能够帮你解决iOS应用程序从本地搜索中获得限制所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1098339.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存