alexrothenberg / motion-addressbook

MIT License
89 stars 30 forks source link

iOS 6 breaks #2

Closed jamonholmgren closed 12 years ago

jamonholmgren commented 12 years ago

I just updated to Xcode 4.5 and iOS 6 and it looks like ABAddressBookCreate is now deprecated in favor of ABAddressBookCreateWithOptions.

https://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABAddressBookRef_iPhoneOS/Reference/reference.html#//apple_ref/doc/uid/TP40007099

It doesn't work at all with ABAddressBookCreate.

More information here:

http://www.bgr.com/2012/08/06/ios-6-beta-4-change-log-now-available/

I'm not familiar enough with the library to do a pull request. Will you be able to update the library in the next week or so?

alexrothenberg commented 12 years ago

Yes I will try to fix this as soon as I can (this week I hope)

jamonholmgren commented 12 years ago

Do we need to have backwards-compatible code detecting which one to use, or will ABAddressBookCreateWithOptions work with iOS 5?

alexrothenberg commented 12 years ago

good point.

I'm not sure how to build one "smart" version that can handle both IOS5 & IOS6. If you know how please let me know :)

Otherwise I'll have to fork and maintain 2 versions of the gem which is not something I'm looking forward to.

jamonholmgren commented 12 years ago

I don't blame you on not wanting to maintain two versions. I have to have this for my current app, so if I find a way I'll do a pull request. :) Thanks for your speedy fix.

alexrothenberg commented 12 years ago

I'm asking for help on the RM group https://groups.google.com/forum/?fromgroups=#!topic/rubymotion/U8BS0BfeIG8

This is an interesting problem and there's got to be some solution ... but I don't (yet) know what it is.

jamonholmgren commented 12 years ago

I'm playing around with it...have some ideas.

jamonholmgren commented 12 years ago

I can't even get ABAddressBookCreateWithOptions or ABAddressBookCreate to work at all, now. Are you able to get them to work? I'm getting a NameError (uninitialized constant).

jamonholmgren commented 12 years ago

I submitted a RubyMotion bug report. Hopefully we can get this resolved ASAP.

alexrothenberg commented 12 years ago

Yeah I can run the ABAddressBookCreateWithOptions version using the head of this gem.

$ rake
     Build ./build/iPhoneSimulator-6.0-Development
  Simulate ./build/iPhoneSimulator-6.0-Development/Untitled.app
(main)> error = nil
=> nil
(main)> ABAddressBookCreateWithOptions(nil, error)
=> #<__NSCFType:0xaa1e350>
(main)> AddressBook.address_book
=> #<__NSCFType:0xaa37fd0>

Let me know what ideas Laurent has...

jamonholmgren commented 12 years ago

I had to use it in my code before it would show up in the REPL, but it looks like it's working.

It looks like we will need an async call to request access and we'll need to do this every time we want access to the address book:

AddressBook.request_access do |granted, error|
  if granted
    self.people = AddressBook::Person.all
    update_table
  elsif error
    App.alert "Error importing contacts."
  else
    App.alert "You can't import contacts if you don't grant access."
  end
end

I have this partially working.

jamonholmgren commented 12 years ago

It works on the simulator, but not on my device. Doing more testing.

jamonholmgren commented 12 years ago

I'm having a hanging issue on my device, but it could be my app code. I'll do a pull request and you can check it on yours (if you like my code).

jamonholmgren commented 12 years ago

Works in iOS 6, but not iOS 5. Closing this and opening a separate issue.