[ 
https://issues.apache.org/jira/browse/CB-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469180#comment-13469180
 ] 

Ronnie Schaniel commented on CB-902:
------------------------------------

Here is the javascript part of adding a contact:

function addToContacts()
{
  if(currentAddress != null)
  {
    console.log("Add " + currentAddress.company_name + " to contacts");
    var contact = navigator.contacts.create({ "displayName" : 
currentAddress.company_name });
    contact.id = currentAddress.company_name;
        
    var contactCompany = new ContactOrganization();
    contactCompany.name = currentAddress.company_name;
    contact.organizations = new Array(contactCompany);
    
    street_and_house = $.trim(currentAddress.street + ' ' + 
currentAddress.house);
    var address = new ContactAddress();
    address.type = 'work';
    address.streetAddress = street_and_house;
    address.postalCode = currentAddress.zip
    address.locality = currentAddress.city;
    address.country = 'Switzerland';
    contact.addresses = new Array(address);
    
    var phoneNumbers = new Array();
    if(currentAddress.phone != null)
    {
      phoneNumbers.push(new ContactField('work', currentAddress.phone, true));
    }
    if(currentAddress.fax != null)
    {
      phoneNumbers.push(new ContactField('work fax', currentAddress.fax, 
false));;
    }
    if(phoneNumbers.length > 0)
    {
      contact.phoneNumbers = phoneNumbers;
    }
    
    if(currentAddress.email != null)
    {
      contact.emails = new Array(new ContactField('work', currentAddress.email, 
true));
    }
    
    if(currentAddress.homepage != null)
    {
      contact.urls = new Array(new ContactField('work', 
currentAddress.homepage, true));
    }
        
    navigator.notification.confirm("Wollen Sie diese Adresse in Ihre Kontakte 
übernehmen?", function(button){ if(button == 1) { contact.save(); } }, "Kontakt 
speichern", "OK,Abbrechen");
  }
}

In CDVContacts.m I get a EXC_BAD_ACCESS at this point:
 [abHelper createAddressBook: ^(ABAddressBookRef addrBook, 
CDVAddressBookAccessError * errorCode) {


I think there is an error in my App and not in your Fix.
                
> iOS 6 - deal with new Privacy functionality in Contacts (ABAddressBook:: 
> ABAddressBookCreateWithOptions)
> --------------------------------------------------------------------------------------------------------
>
>                 Key: CB-902
>                 URL: https://issues.apache.org/jira/browse/CB-902
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 1.8.0
>         Environment: iOS 6 DP1
>            Reporter: Shazron Abdullah
>            Assignee: Braden Shepherdson
>            Priority: Critical
>              Labels: iOS6
>             Fix For: 2.2.0
>
>
> Currently crashes if the user does not have AddressBook permission on iOS 6.
> The user will get a popup dialog similar to the Geolocation permissions 
> dialog. When creating an address book, we should handle the condition where 
> the app does not have permission, and the address book returned is NULL. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to