I have an app that uses the Address Book. When running in iOS 6 it runs this code when the user does something that requires Address Book access.
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
{
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error)
{
if (granted)
{
showContactChooser();
}
});
CFRelease(addressBookRef);
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized)
{
showContactChooser();
}
else
{
showAccessDeniedAlert();
}
This works perfectly: I am able to read the contacts information and when the user denied access, the app reacts accordingly.
However, if the user:
- Allows Contacts access in the app,
- Quits the app,
- Goes to Settings->Privacy->Contacts and disables Contacts access for the app,
- Runs the app,
- While the app is running in background goes to settings and enables Contact access for the app,
the app immediately crashes inside main()
with no exception information or a meaningful stack trace. I tried turning on the "all exceptions" and [NSException raise]
breakpoint, but that didn't give me any more information.
The crash can be reproduced even if the app doesn't run the above code during the launch.
What's happening here? Is there a callback that I should be subscribing to?