Skip to content

Commit

Permalink
Merge pull request #6711 from cheekiatng/TIMOB-18359-4_0_X
Browse files Browse the repository at this point in the history
[TIMOB-18359](4_0_X) iOS: fix ringtone texttone properties in peoplePicker
  • Loading branch information
vishalduggal committed Mar 11, 2015
2 parents 1ba9e6e + fc11b47 commit 265f970
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apidoc/Titanium/Contacts/Contacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ properties:
summary: |
Function to call when a property is selected. Must not be used with `selectedPerson`
property.
Note: If ringtone or texttone is selected, null values are returned, since these are unsupported
by Apple.
platforms: [iphone, ipad]
type: Callback<Object>
optional: true
Expand Down
31 changes: 28 additions & 3 deletions iphone/Classes/ContactsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
#define kABAuthorizationStatusAuthorized 3
#endif

#define appleUndocumentedBirthdayProperty 999
#define appleUndocumentedToneProperty 16
#define appleUndocumentedRingToneIdentifier -1
#define appleUndocumentedRingVibrationIdentifier -101
#define appleUndocumentedTextToneIdentifier -2
#define appleUndocumentedTextVibrationIdentifier -102

@implementation ContactsModule

void CMExternalChangeCallback (ABAddressBookRef notifyAddressBook,CFDictionaryRef info,void *context)
Expand Down Expand Up @@ -537,7 +544,26 @@ - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)p
NSString *propertyName = nil;
id value = [NSNull null];
id label = [NSNull null];
if (identifier == kABMultiValueInvalidIdentifier) {

//if statement to handle undocumented ring and text tone property from apple
//only implemented in this method, since apple doesn't want people fooling around with these
//null values are accompanied. Only inform app that user selected this property in the peoplePicker
if (property == appleUndocumentedToneProperty)
{
if (identifier == appleUndocumentedRingToneIdentifier) {
propertyName = @"ringTone";
}
if (identifier == appleUndocumentedRingVibrationIdentifier) {
propertyName = @"ringVibration";
}
if (identifier == appleUndocumentedTextToneIdentifier) {
propertyName = @"textTone";
}
if (identifier == appleUndocumentedTextVibrationIdentifier) {
propertyName = @"textVibration";
}
}
else if (identifier == kABMultiValueInvalidIdentifier) {
propertyName = [[[TiContactsPerson contactProperties] allKeysForObject:[NSNumber numberWithInt:property]] objectAtIndex:0];

// Contacts is poorly-designed enough that we should worry about receiving NULL values for properties which are actually assigned.
Expand All @@ -548,7 +574,7 @@ - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)p
}
} else {
//birthdays for iOS8 is multivalue and NOT kABPersonBirthdayProperty only in DELEGATE, but undocumented in Apple
if ([TiUtils isIOS8OrGreater] && property == 999) {
if ([TiUtils isIOS8OrGreater] && property == appleUndocumentedBirthdayProperty) {
CFTypeRef val = nil;
if (identifier == 0) {
propertyName = @"birthday";
Expand Down Expand Up @@ -590,7 +616,6 @@ - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)p
if (CFlabel != NULL) {
CFRelease(CFlabel);
}

CFRelease(multival);
}
}
Expand Down

0 comments on commit 265f970

Please sign in to comment.