Appcelerator Titanium startMonitoringForRegion
我正在使用 Appcelerator Titanium 来构建我的移动应用程序(iPhone + Android)。 我在他们的文档中找到了 titan.geolocation ,但我找不到任何方法,例如我们在 iOS 中查找的“startMonitoringForRegion”或“startMonitoringSignificantLocationChanges”。但它的属性定义为“ERROR_REGION_MONITORING_DENIED”,因此必须有某种区域监视方法。
那么它是在文件中没有定义还是我遗漏了一些东西。我尝试使用谷歌搜索但找不到它。
基本上我想要的就是当用户进入特定区域时向用户显示一些警报,即使应用程序处于后台(就像我以前在 iOS 中使用 startMonitoringForRegion 所做的那样)。钛也有可能吗?请帮忙。
I am using Appcelerator Titanium for building my mobile app(iphone + android).
I found titanium.geolocation in their documents , but I couldn't find any method such as "startMonitoringForRegion" or "startMonitoringSignificantLocationChanges" as we use to find in iOS. but it has properties defined as "ERROR_REGION_MONITORING_DENIED", so there must be some region monitoring method.
So is it not defined in documents or am I missing something. I tried Googling but couldn't find it.
Bascically all I want is to present user with some alert when user enters a particular region, even when the app is in background ( as I used to do it with startMonitoringForRegion in iOS). So is it possible with Titanium. Please Help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“对于不需要常规位置事件流的应用程序,您应该考虑使用
startMonitoringSignificantLocationChanges
方法来开始传递事件。此方法更适合大多数只需要一个位置事件流的应用程序。仅当用户移动相当远的距离时才需要更新初始用户位置。此界面仅在检测到设备关联的蜂窝塔发生变化时才提供新事件,从而减少更新频率并显着提高功耗。”根据Apple定义的标准,您似乎所需要做的就是设置
Titanium.Geolocation.distanceFilter
,以便事件继续每*米触发。没有直接的文档,但是如果您检查在 KS 资源中,您将看到
geolocation.js
文件使用了多种未记录的功能。我必须基本上复制它并删除我的应用程序不需要的内容。https://github.com/appcelerator/KitchenSink/blob /master/Resources/examples/geolocation.js#L345
startMonitoringForRegion
应该是相同的想法,但您需要按照此<中的定义设置精度常量
href="http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Geolocation-module" rel="nofollow">文档。"For applications that do not need a regular stream of location events, you should consider using the
startMonitoringSignificantLocationChanges
method to start the delivery of events instead. This method is more appropriate for the majority of applications that just need an initial user location fix and need updates only when the user moves a significant distance. This interface delivers new events only when it detects changes to the device’s associated cell towers, resulting in less frequent updates and significantly better power usage."By that standard that Apple defines it would seem that all you need is to set the
Titanium.Geolocation.distanceFilter
so that the event continues to fire every * metersThere is no documentation on it directly however if you check out the KS resources you'll see the
geolocation.js
file uses several abilities not documented. I had to basically copy it and strip out what I didn't need for my app.https://github.com/appcelerator/KitchenSink/blob/master/Resources/examples/geolocation.js#L345
startMonitoringForRegion
should be the same idea but you will need to set theaccuracy constant
as defined in this documentation.您可以尝试将侦听器附加到
regionChanged
事件http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object
you can try and attach a listener to
regionChanged
eventhttp://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object