Closed jamonholmgren closed 12 years ago
Yes I will try to fix this as soon as I can (this week I hope)
Do we need to have backwards-compatible code detecting which one to use, or will ABAddressBookCreateWithOptions work with iOS 5?
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.
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.
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.
I'm playing around with it...have some ideas.
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).
I submitted a RubyMotion bug report. Hopefully we can get this resolved ASAP.
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...
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.
It works on the simulator, but not on my device. Doing more testing.
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).
Works in iOS 6, but not iOS 5. Closing this and opening a separate issue.
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?