开发者

Appcelerator Titanium startMonitoringForRegion

I am using Appcelerator Titanium for building my mobile 开发者_C百科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.


"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.


you can try and attach a listener to regionChanged event

http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜