Appcelerator Titanium startMonitoringForRegion

发布于 2024-10-31 09:21:34 字数 401 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

又怨 2024-11-07 09:21:34

“对于不需要常规位置事件流的应用程序,您应该考虑使用 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 * meters

There 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 the accuracy constant as defined in this documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文