Skip to content
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

[TIMOB-18359](4_0_X) iOS: fix ringtone texttone properties in peoplePicker #6711

Merged
merged 2 commits into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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