-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contacts API #686
Comments
Our current thinking around all of those APIs is that it's going to be left to whoever bridges it first. If we need it internally we'll build it and dogfood it. When it becomes good and stable, we'll include it in core. But if someone else in the community beats us to it and the package on npm gains significant traction, we'll likely bring it in core instead (assuming the author wants to). The good part is that the plugin api is public and what is being used for all the existing components today, so no one has a disadvantage. We don't have any plans for a feature that would use the contact api right now, so it's unlikely going to be coming from us in the next few months. This whole plugin is still very much up in the air, please let me know if you have ideas on how to make it work best for everyone |
@colinramsay - if you're interested in building a bridge, ping me as notbrent on irc (#reactnative on freenode) and I can help you get started! |
I've started building a basic Contacts API for a project I'm working on. I'll try and pop it on Github this afternoon or tomorrow if it would be useful for people. EDIT: the code I'm using is here: https://gist.github.com/darylrowland/62a5f12981c4669394a8 |
@darylrowland would love to check that out |
I've begun work on this a had a few questions about the NativeModules bridge Am I limited to String for error and params in the callbacks? What would it look like to return a object or array of objects if that is possible? Is there a standard for what errors should return? I realize the Native Modules are still a work in progress, but what is the expected way to package/distribute? @brentvatne showed me an example of his react-native-login which is an example xcode project that includes his actual bridge. By the way, I was psyched out how simple it was to extend this and get it working! Current code. Not complete, but any advice would be appreciated as I do not come from an objective-c background. (I intend to paginate the getAllContacts call, this was just to see if it was working, and it is!!) @import AddressBook;
#import "AddressBook.h"
@implementation AddressBook
- (void)hasABAuth:(RCTResponseSenderBlock)callback {
RCT_EXPORT(hasAuth);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusDenied ||
ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusRestricted){
callback(@[[NSNull null], @"denied"]);
} else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized){
callback(@[[NSNull null], @"authorized"]);
} else { //ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined
callback(@[[NSNull null], @"undetermined"]);
}
}
- (void)requestABAuth:(RCTResponseSenderBlock)callback {
RCT_EXPORT(requestAuth);
ABAddressBookRequestAccessWithCompletion(ABAddressBookCreateWithOptions(NULL, nil), ^(bool granted, CFErrorRef error) {
if (!granted){
callback(@[[NSNull null], @"denied"]);
return;
}
callback(@[[NSNull null], @"authorized"]);
});
}
-(void)getAllContacts:(RCTResponseSenderBlock)callback {
RCT_EXPORT();
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
NSArray *allContacts = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBookRef);
NSLog(@"%@", allContacts);
}
@end |
callback(@[@[@1], @{@"foo": @"bar"}])
For passing Error-like objects, see |
https://github.com/mattotodd/react-native-addressbook-ios Comments appreciated |
Thanks @mattotodd edit continuing work over @ react-native-addressbook-ios |
@rt2zz replied to your issue on my repo. sorry, was out of the country this past week with little access to email, only got notified when you posted here. thx |
Thanks @mattotodd for putting that together 😄 |
Can you please re-open this issue? We still don't have Android support. See my bug bounty and the issue here morenoh149/react-native-contacts#10 |
@niftylettuce the react-native team does not build out anything they don't directly use, Contacts being one of them. If a third-party builds something and it gets good feedback, it can be pulled back in I started an iOS version https://github.com/mattotodd/react-native-addressbook-ios I can take a look at an Android version, but might take a little time |
@mattotodd can you peak into morenoh149/react-native-contacts#13 (comment) |
💅'd it @mattotodd |
@brentvatne what did I nail ? |
I've been using https://github.com/rt2zz/react-native-contacts but it is lacking in a number of ways, not that they aren't working on it, just that it's kind of important so I want to bring this up for discussion again. This is the sort of thing I think could really benefit by being part of official React Native, because it's pretty fundamental to a lot of apps. I'd estimate more apps would use contacts than a number of the official components (not that they're great to have too). I propose that https://github.com/rt2zz/react-native-contacts be slated to be part of the official React Native, as a Contacts component. |
@pickhardt It should stay as a different module IMO. The core team won't likely to be able to work on it. So it's better to be a third party module where it can get better care. |
Lets be honest, FB already knows all your contacts. They have no need to support the native contacts api, so like @satya164 said, it makes more sense for a third party to take care of it. |
I've had a lot of success with https://github.com/axemclion/react-native-cordova-plugin (see my fork for a bug I patched), in combination with official Cordova plugins like https://github.com/apache/cordova-plugin-contacts. It's a port basically and has helped out in meanwhile. |
Doesn't look like there's anything been mentioned about a way of interfacing with the address book on a device. Is this a planned feature or something that'll be deferred to the community?
The text was updated successfully, but these errors were encountered: