我发现了 Titanium Appcelerator Studio 中的一个 bug,当联系人对象拥有自定义电话标签时,
phone
对象返回 undefined
。
不幸的是,修复这个问题可能需要更多的时间,但好消息是我可以修改 Objective-C 的构建类来提供个人信息。
/build/iphone/classes/TiContactsPerson.m 内容如下:
+(NSDictionary*)multiValueLabels
{
if (multiValueLabels == nil) {
multiValueLabels =
[[NSDictionary alloc] initWithObjectsAndKeys:(NSString*)kABHomeLabel,@"home", // Generic labels
kABWorkLabel,@"work",
kABOtherLabel,@"other",
kABPersonPhoneMobileLabel,@"mobile", // Phone labels
kABPersonPhonePagerLabel,@"pager",
kABPersonPhoneWorkFAXLabel,@"workFax",
kABPersonPhoneMainLabel,@"main",
kABPersonPhoneIPhoneLabel,@"iPhone",
kABPersonPhoneHomeFAXLabel,@"homeFax",
kABPersonSocialProfileServiceFacebook,@"facebookProfile",// Social Profile Labels
kABPersonSocialProfileServiceFlickr,@"flickrProfile",
kABPersonSocialProfileServiceGameCenter,@"gameCenterProfile",
kABPersonSocialProfileServiceLinkedIn,@"linkedInProfile",
kABPersonSocialProfileServiceMyspace,@"myspaceProfile",
kABPersonSocialProfileServiceSinaWeibo,@"sinaWeiboProfile",
kABPersonSocialProfileServiceTwitter,@"twitterProfile",
kABPersonInstantMessageServiceAIM,@"aim", // IM labels
kABPersonInstantMessageServiceICQ,@"icq",
kABPersonInstantMessageServiceJabber,@"jabber",
kABPersonInstantMessageServiceMSN,@"msn",
kABPersonInstantMessageServiceYahoo,@"yahoo",
kABPersonInstantMessageServiceQQ,@"qq",
kABPersonInstantMessageServiceSkype,@"skype",
kABPersonInstantMessageServiceGoogleTalk,@"googletalk",
kABPersonInstantMessageServiceGaduGadu,@"gadugadu",
kABPersonInstantMessageServiceFacebook,@"facebook",
kABPersonMotherLabel,@"mother", // Relation labels
kABPersonFatherLabel,@"father",
kABPersonParentLabel,@"parent",
kABPersonSisterLabel,@"sister",
kABPersonBrotherLabel,@"brother",
kABPersonChildLabel,@"child",
kABPersonFriendLabel,@"friend",
kABPersonSpouseLabel,@"spouse",
kABPersonPartnerLabel,@"partner",
kABPersonManagerLabel,@"manager",
kABPersonAssistantLabel,@"assistant",
kABPersonAnniversaryLabel,@"anniversary", // Date label
kABPersonHomePageLabel,@"homepage", // URL label
nil];
}
return multiValueLabels;
}
它不包括用户为电话号码设置的自定义标签,这就是为什么当联系人有自定义标签时,phone
数组返回未定义的原因。
我的问题是如何获取用户创建的所有自定义标签,并将它们推送到上述数组中?
注意:我已经向Appcelerator Jira报告了这个错误。
非常感谢任何建议。