iPhone 6 contacts issue

I am unable to access contacts on iPhone 6, error is “SyntaxError: Unexpected EOF”,
everything works fine on iphone 4, 5, 5s.

var obj = new ContactFindOptions();
    obj.filter = "";
    obj.multiple = true;
    navigator.contacts.find(["displayName", "name", "phoneNumbers"], function(contacts){
        contacts_success(contacts, callback);
    }, contacts_fail, obj);

i am using cordova 3.5.

tried your code, it does work fine with my Iphone 6+

who does throw this error? cordova or angular?

At last i solved my issue. This issue occurs when any contact in your phonebook has name with a new line.

If anyone is reading this topic, you can now use ngCordova Contacts plugin to access device contacts.

@mrameezraja

I am encountering the same issue.

How did you figure out which contact has a newline character?

Is there a better solution? This seems to be a bug int he contacts plugin? No?

Yes it is a bug in contacts plugin. It usually occurs when contacts are imported from google, facebook etc.

I have fixed it in a plugin (https://github.com/mrameezraja/cordova-async-contacts-plugin (ios only)).

I have also submit a bug but they were not able to reproduce it.
(https://issues.apache.org/jira/browse/CB-8290)

But you can also made some modifications in cordova’s plugin.

add this function before @end in CDVContacts.m plugin.

NSString *ReplaceSpecialChars(NSString *inputString)
{
   NSString* returnString = inputString != nil ? inputString : @"";
   if(inputString != [NSNull null] && [inputString length] > 0){
        NSArray *split = [inputString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
        split = [split filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]];
        NSString *res = [split componentsJoinedByString:@" "];
        returnString = res;

    };
    return returnString;
}

Now can make some changes in CDVContacts.m, FInd this function.

- (void)search:(CDVInvokedUrlCommand*)command
{
    ....
   
   NSMutableArray* returnContacts = [NSMutableArray arrayWithCapacity:1];

            if ((matches != nil) && ([matches count] > 0)) {
                // convert to JS Contacts format and return in callback
                // - returnFields  determines what properties to return
                @autoreleasepool {
                    int count = multiple == YES ? (int)[matches count] : 1;

                    for (int i = 0; i < count; i++) {
                        CDVContact* newContact = [matches objectAtIndex:i];
                        **// make your changes here like, i don't know exact :(**
**                        // newContact.name = ReplaceSpecialChars(newContact.name);**
**                        // newContact.middlename = ReplaceSpecialChars(newContact.middlename)**;
                        NSDictionary* aContact = [newContact toDictionary:returnFields];
                        [returnContacts addObject:aContact];
                    }
                }
            }