rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

BW::Location CLLocationManagerDelegate method deprecation #421

Closed cognitiveflux closed 9 years ago

cognitiveflux commented 9 years ago

The CLLocationManagerDelegate method locationManager:didUpdateToLocation:fromLocation has been deprecated since two prior major version of iOS and recommends locationManager:didUpdateLocations instead.

While the new delegate method guarantees at least one CLLocation object in the response, additional objects may or may not be included.

I can create a branch and implement the new delegate method, however I created this issue to collect feedback on how it should be implemented because a result[:from] value is no longer guaranteed as provided in this Callback.

A possible implementation would require result[:from] to be removed and replaced with an optional result[:previous_locations], for example. Alternatively, the callback could store the previous location in an instance variable and return it for result[:from] in the event that the locations array returned by the delegate method only has one member, thus preserving the BW::Location functionality. That being said, in the current implementation result[:from] will ways be nil on the first location update.

markrickert commented 9 years ago

It would be great if you could do this! We've been having difficulty getting the location working properly on ios 8 and that's probably why.

cognitiveflux commented 9 years ago

I created a branch and committed 5eba0ae2d587dd7a41b53507e22df9ee661048e1, the specs (updated) pass, though I haven't been able to test actual location updates in either the simulator or device. Is there a simple location app using BW::Location I can pull and test with?

cognitiveflux commented 9 years ago

Created pull request https://github.com/rubymotion/BubbleWrap/pull/422, though the build is failing on Travis with a *** Cannot start simulator: (null) error. Previous pull request from another user had the same issue, not sure if it's using the latest simulator. I ran the rspec tests locally, tested on the simulator and also on a device and didn't have any observed issues.

Siggs2000 commented 9 years ago

Hey everyone,

I was just checking in to see if there was any solution to this that I've missed. I notice that I get location errors on simulator pretty often unless I rake:clean and rebuild all the time.

It works often but not all the time... randomly...

I'll end up with this error:

undefined method `coordinate' for {...}:Hash (NoMethodError)
cognitiveflux commented 9 years ago

Are you using a branch with #422? I retried several times to run the tests but running tests against master failed and I didn't have the time to figure out what other commit was causing the tests to fail before trying to test with my branch. I ended up implementing location services without BW.

Separate issue, I know that if the simulator is left running (~ 15 minutes) it stops responding to location requests, whether using BW+422 or implementing CLLocationManagerDelegate, so at least that much I would attribute as an issue directly with the Simulator because I have never come across it on a device.

cognitiveflux commented 9 years ago

422 merged, closing issue.

markrickert commented 9 years ago

:+1: