Skip to content

Commit e7d3cdf

Browse files
Merge branch 'bugfix-13639' into release-6.6.4
2 parents 29acb49 + 6d446e0 commit e7d3cdf

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

docs/notes/bugfix-13639.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# mobilepickcontact works under ios 7 but not under ios 8

engine/src/mbliphonecontact.mm

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,12 @@ -(void)doShowPickContact
695695
// Show the picker
696696
m_running = true;
697697

698-
[MCIPhoneGetViewController() presentModalViewController:m_pick_contact animated:YES];
698+
if (MCmajorosversion >= 500)
699+
{
700+
[MCIPhoneGetViewController() presentViewController:m_pick_contact animated:YES completion:nil];
701+
}
702+
else
703+
[MCIPhoneGetViewController() presentModalViewController:m_pick_contact animated:YES];
699704
}
700705
}
701706

@@ -706,7 +711,9 @@ -(bool)showPickContact: (int32_t&) r_chosen
706711
while (m_running)
707712
MCscreen -> wait(1.0, False, True);
708713

709-
[self dismissController];
714+
// PM-2014-10-10: [[ Bug 13639 ]] On iOS 8, the ABPeoplePickerNavigationController is dismissed in peoplePickerNavigationController:didSelectPerson. If [self dismissController] is called, then the completion block of dismissViewControllerAnimated:completion:^(){} in doDismissController is never called. So m_finish never becomes true and the app freezes
715+
if (MCmajorosversion < 800)
716+
[self dismissController];
710717

711718
// Return the result
712719
if (m_selected_person == kABRecordInvalidID)
@@ -717,6 +724,25 @@ -(bool)showPickContact: (int32_t&) r_chosen
717724
return m_success;
718725
}
719726

727+
// PM-2014-10-10: [[ Bug 13639 ]] In iOS 8, this is the replacement for peoplePickerNavigationController:shouldContinueAfterSelectingPerson
728+
// Called after a person has been selected by the user. It seems that it is also dismissing the ABPeoplePickerNavigationController (m_pick_contact), so we should not call [self dismissController] in showPickContact.
729+
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person;
730+
{
731+
if (person != NULL)
732+
m_selected_person = ABRecordGetRecordID(person);
733+
m_running = false;
734+
return;
735+
}
736+
737+
738+
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
739+
{
740+
if (person != NULL)
741+
m_selected_person = ABRecordGetRecordID(person);
742+
m_running = false;
743+
return;
744+
}
745+
720746
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
721747
{
722748
if (person != NULL)
@@ -1134,7 +1160,21 @@ bool MCSystemGetContactData(MCExecContext &r_ctxt, int32_t p_contact_id, MCVaria
11341160
bool t_success = true;
11351161

11361162
ABAddressBookRef t_address_book = nil;
1137-
t_success = nil != (t_address_book = ABAddressBookCreate());
1163+
1164+
// PM-2014-10-08: [[ Bug 13621 ]] ABAddressBookCreate is deprecated in iOS 6. Use ABAddressBookCreateWithOptions instead
1165+
if (MCmajorosversion < 600)
1166+
{
1167+
// Fetch the address book
1168+
t_address_book = ABAddressBookCreate();
1169+
}
1170+
else
1171+
{
1172+
// The ABAddressBookRef created with ABAddressBookCreateWithOptions will initially not have access to contact data. The app must then call ABAddressBookRequestAccessWithCompletion to request this access.
1173+
t_address_book = ABAddressBookCreateWithOptions(NULL, NULL);
1174+
requestAuthorization(t_address_book);
1175+
}
1176+
1177+
t_success = (nil != t_address_book);
11381178

11391179
ABRecordRef t_person = nil;
11401180
if (t_success)

0 commit comments

Comments
 (0)