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

Updated CLLocationManagerDelegate method for locationManager:didUpdateLocations #422

Closed cognitiveflux closed 9 years ago

cognitiveflux commented 9 years ago

Updated CLLocationManagerDelegate methods for locationManager:didUpdateLocations

Changed locationManager:didUpdateToLocation:fromLocation to locationManager:didUpdateLocations Preserved callback result[:from] key-value by storing previous location in an instance variable Added result[:previous] to include additional locations returned by the delegate method Updated inline documentation for location.rb Updated spec BW::Location Updated README.md with information about 'result[:previous]' value

Updated RSpec tests passed, tested on iOS Simulator 8.0 (iPhone 6) and iPhone 4S (iOS 8.0.2) device, compiled with RubyMotion 2.34.

markrickert commented 9 years ago

I hate it when Travis fails and you look at the log and see zero errors and exit status: 0. :unamused:

Re-running the build.

markrickert commented 9 years ago

It looks like the failure is actually nothing related to this PR... The command "bundle exec rake spec" exited with 2. It's the UIActionSheet that's causing the issue. I'll try and sort it out in the main BW repo.

markrickert commented 9 years ago

Sorry it took me so long to check this out... this fixes my problem!

I also tested it in iOS 7 and it appears to be working just fine when built with the iOS 8.1 SDK.

Can you rebase master into your branch so all other tests pass (there were some issues with UIAlertView tests in iOS 8 that I fixed in master).

Then we'll get this merged asap and release a new version.

Thanks so much for doing the legwork on this, @cognitiveflux!

otzy007 commented 9 years ago

Looks OK. It's always starting with a position and on the iPhone 4S(8.0.2) it works flawless. Only on the simulator I get {:error => 3} when I change the location, for example from City Run to Apple and then back to City Run.

markrickert commented 9 years ago

Reset the simulator, quit it and then rake clean:all && bundle install && rake pod:install && rake and see if that fixes the issue in the sim. My new gem might help you with this :) https://github.com/MohawkApps/reset-sim

Glad to get some more confirmation here that this is working!

otzy007 commented 9 years ago

@markrickert yeah. I did all of that...

{:to=>#<CLLocation:0x11cb0b90>, :from=>#<CLLocation:0x11ee7fe0>, :previous=>[]}
{:to=>#<CLLocation:0x18e03560>, :from=>#<CLLocation:0x11cb0b90>, :previous=>[]}
{:error=>3}
markrickert commented 9 years ago

But that just happens when you manually change your location in the debug menu of the sim, correct?

cognitiveflux commented 9 years ago

No idea why the build is failing on Travis again, no changes to the branch other than a rebase ...

otzy007 commented 9 years ago

@markrickert Yes. It's happening when I change the location in the simulator(Xcode 6.0.1)

markrickert commented 9 years ago

Travis is a fickle mistress. I'll reinit another build on this branch.

cognitiveflux commented 9 years ago

Looking at the commit history and trying to keep it clean, not sure if you want me to create a new branch and resubmit a pull request, let me know

markrickert commented 9 years ago

I'm OK leaving as is... we all personally have a sordid past of things we'd rather forget... why not BubbleWrap too!!? :grin:

otzy007 commented 9 years ago

@cognitiveflux you can rebase HEAD~6 -i and instead of pick for the last 5 you put "f". This way it will make a single commit.

cognitiveflux commented 9 years ago

@otzy007 pretty sure I figured out why you're getting that error, let me guess, you're using significant change tracking? Actually surprised this hasn't been reported more, these lines only restart immediate location tracking, they don't restart significant change tracking, I'll make the change and add it to this pull request

markrickert commented 9 years ago

Yeah, I don’t think this will be an issue since it seems to work just fine on the device… the only time the app would stop tracking and return an error would be if the user turned off their phone, went a long distance, then turned it back on. In which case, your app wouldn’t likely be active anymore anyways.

cognitiveflux commented 9 years ago

I'll create a separate pull request for the restart patch since it has nothing to do with the location services deprecated method. Local tests are failing on a test nothing related to location services:

.window
  - returns UIApplication.sharedApplication.keyWindow [FAILED - UIWindow.==(UIView) failed]
markrickert commented 9 years ago

Re the failure - are you running xcode 6.0.1 and ios 8.1? Apple did some weird things with the way alertviews work in ios 8.

cognitiveflux commented 9 years ago

I am, however Travis is failing with the same one, looks like it's this spec

otzy007 commented 9 years ago

@cognitiveflux I'm using just BW::Location.get without any parameters. This bug that I'm having in the simulator, kCLErrorDomain code=0, happens in the RubyMotionSamples repo too. It's probably a simulator bug. I'm all :+1: :+1: to merge it :wink:

cognitiveflux commented 9 years ago

@otzy007 would you mind trying your test against https://github.com/rubymotion/BubbleWrap/pull/432 to see if that resolves it?

markrickert commented 9 years ago

Finally getting around to merging this so i can release a new version. Sorry about the delay and thanks for the contribution!