ABAddressBookSave is failing without error

46 views Asked by At

I am trying to create a contact group in native by using following code, The Scenario i am trying is : Add any outlook account in native mail then enable contact sync, this will create a contact group. After this if i am trying to create a group from my App then its failing ..

ABAddressBookRef addressBook = ABAddressBookCreate();
    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (granted) {
                CFErrorRef error = NULL;
                ABRecordRef worxMailGroup = ABGroupCreate();
                BOOL success = ABRecordSetValue(worxMailGroup,kABGroupNameProperty,(__bridge CFTypeRef) @"TestGroup2",&error);
                if (success) {
                    bool bStatus = ABAddressBookAddRecord(addressBook, worxMailGroup, &error);
                    if (bStatus) {
                        bStatus = ABAddressBookSave(addressBook, &error);
                        // bStatus is false and error also nil ..
                    }
                }
            }
        });
    });

Thanks

0

There are 0 answers