Ios Cordova联系人选择器插件调用
我正在使用以下插件从iOS应用程序中的联系人中选择电话号码: 有两个问题: 当我点击联系人时,它会显示他们的所有信息,包括电子邮件和地址。有没有办法把它限制在电话号码上?此外,当我点击一个电话号码时,它会开始拨打该号码,而不是提醒该号码 代码如下:Ios Cordova联系人选择器插件调用,ios,objective-c,cordova,contacts,Ios,Objective C,Cordova,Contacts,我正在使用以下插件从iOS应用程序中的联系人中选择电话号码: 有两个问题: 当我点击联系人时,它会显示他们的所有信息,包括电子邮件和地址。有没有办法把它限制在电话号码上?此外,当我点击一个电话号码时,它会开始拨打该号码,而不是提醒该号码 代码如下: #import "PickContact.h" #import <Cordova/CDVAvailability.h> @implementation PickContact; @synthesize callbackID; - (
#import "PickContact.h"
#import <Cordova/CDVAvailability.h>
@implementation PickContact;
@synthesize callbackID;
- (void) chooseContact:(CDVInvokedUrlCommand*)command{
self.callbackID = command.callbackId;
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self.viewController presentViewController:picker animated:YES completion:nil];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
if (kABPersonEmailProperty == property)
{
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
int index = ABMultiValueGetIndexForIdentifier(multi, identifier);
NSString *email = (__bridge NSString *)ABMultiValueCopyValueAtIndex(multi, index);
NSString *displayName = (__bridge NSString *)ABRecordCopyCompositeName(person);
ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString* phoneNumber = @"";
for(CFIndex i = 0; i < ABMultiValueGetCount(multiPhones); i++) {
if(identifier == ABMultiValueGetIdentifierAtIndex (multiPhones, i)) {
phoneNumber = (__bridge NSString *)ABMultiValueCopyValueAtIndex(multiPhones, i);
break;
}
}
NSMutableDictionary* contact = [NSMutableDictionary dictionaryWithCapacity:2];
[contact setObject:email forKey: @"emailAddress"];
[contact setObject:displayName forKey: @"displayName"];
[contact setObject:phoneNumber forKey: @"phoneNr"];
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:contact] toSuccessCallbackString:self.callbackID]];
[self.viewController dismissViewControllerAnimated:YES completion:nil];
return NO;
}
return YES;
}
- (BOOL) personViewController:(ABPersonViewController*)personView shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
return YES;
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[self.viewController dismissViewControllerAnimated:YES completion:nil];
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsString:@"PickContact abort"]
toErrorCallbackString:self.callbackID]];
}
@end
#导入“PickContact.h”
#进口
@执行联络;
@合成callbackID;
-(void)选择contact:(CDVInvokedUrlCommand*)命令{
self.callbackID=command.callbackID;
ABPeoplePickerNavigationController*picker=[[ABPeoplePickerNavigationController alloc]init];
picker.peoplePickerDelegate=self;
[self.viewController presentViewController:picker动画:是完成:无];
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
选择人员后应继续:(ABRecordRef)人员
属性:(ABPropertyID)属性
标识符:(ABMultiValueIdentifier)标识符
{
如果(KabbersoneMailProperty==属性)
{
ABMultiValueRef multi=ABRecordCopyValue(person,kABPersonEmailProperty);
int index=ab多值GetIndexForIdentifier(多值,标识符);
NSString*电子邮件=(uu桥NSString*)ABMULTIVALUECOPYVALUATINDEX(multi,索引);
NSString*displayName=(uu桥NSString*)ABRecordCopyCompositeName(个人);
ABMultiValueRef multiPhones=ABRecordCopyValue(person,kABPersonPhoneProperty);
NSString*phoneNumber=@;
对于(CFIndex i=0;i
谢谢。该错误现已在1.0.4版中修复