[ 
https://issues.apache.org/jira/browse/CB-9396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vladimir Kotikov updated CB-9396:
---------------------------------
    Description: 
We are using phonegap and angularjs on our mobile app.. We are currently 
getting phone contacts and it is crashing on iphone4/s only. It is working on 
android and iphone 6. I can't seem to find where the error is.

Here is the code..

{noformat}

module.controller('someControllerName', ['$scope', '$http', function ($scope, 
$http) {
    // find all contacts with 'Bob' in any name field
    var options = new ContactFindOptions();
    options.filter = "";
    options.multiple = true;
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, loadAllContacts, onError, options);
    $scope.viewContact = function (contact) {
        buxMainNav.pushPage("contact_details.html",
            { "animation": "slide", phone_contact: contact }
        );
    };
    $scope.$watch('searchContacts', function (data) {
        if (data != undefined) {
            // find all contacts with 'Bob' in any name field
            var options = new ContactFindOptions();
            options.filter = data;
            options.multiple = true;
            var fields = ["displayName", "name"];
            navigator.contacts.find(fields, loadAllContacts, onError, options);
            $scope.viewContact = function (contact) {
                buxMainNav.pushPage("contact_details.html",
                    { "animation": "slide", phone_contact: contact }
                );
            };
        }
    });
}]);
function loadAllContacts(contacts) {
    var cSort = function (a, b)
    { aName = a.name.givenName; bName = b.name.givenName; return aName < bName 
? -1 : (aName == bName ? 0 : 1); }
    ;
    var scope = 
angular.element(document.getElementById("contacts-controller")).scope();
    scope.nocontactsresults = "";
    scope.$apply(function () {
        contacts = contacts.sort(cSort);
        scope.phoneContacts = contacts;
        if (scope.phoneContacts.length < 1)
            { scope.nocontactsresults = "No Results"; }
        else
            { scope.nocontactsresults = ""; }
    });
};
function onError(contactError) {
    ons.notification.alert(
    { message: "Unable to access phonebook contacts.", title: "Contacts" }
    );
};
{noformat}

  was:
We are using phonegap and angularjs on our mobile app.. We are currently 
getting phone contacts and it is crashing on iphone4/s only. It is working on 
android and iphone 6. I can't seem to find where the error is.

Here is the code..

module.controller('someControllerName', ['$scope', '$http',  function($scope, 
$http) {
    // find all contacts with 'Bob' in any name field
    var options      = new ContactFindOptions();
    options.filter   = "";
    options.multiple = true;
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, loadAllContacts, onError, options);

    $scope.viewContact = function (contact) {
        buxMainNav.pushPage("contact_details.html", {
            "animation": "slide",
            phone_contact: contact
        });
    };

    $scope.$watch('searchContacts', function(data) {
        if (data != undefined) {
            // find all contacts with 'Bob' in any name field
            var options      = new ContactFindOptions();
            options.filter   = data;
            options.multiple = true;
            var fields = ["displayName", "name"];
            navigator.contacts.find(fields, loadAllContacts, onError, options);

            $scope.viewContact = function (contact) {
                buxMainNav.pushPage("contact_details.html", {
                    "animation": "slide",
                    phone_contact: contact
                });
            };
        }
    });
}]);


function loadAllContacts(contacts) {
    var cSort = function(a, b) {
        aName = a.name.givenName;
        bName = b.name.givenName;
        return aName < bName ? -1 : (aName == bName ? 0 : 1);
    };


    var scope = 
angular.element(document.getElementById("contacts-controller")).scope();
    scope.nocontactsresults = "";
    scope.$apply(function(){
        contacts = contacts.sort(cSort);
        scope.phoneContacts = contacts;
        if (scope.phoneContacts.length < 1) {
            scope.nocontactsresults = "No Results";
        } else {
            scope.nocontactsresults = "";
        }
    })
};

function onError(contactError) {
    ons.notification.alert({
        message: "Unable to access phonebook contacts.",
        title: "Contacts"
    });
};


> phonegap app crashes on getting contacts
> ----------------------------------------
>
>                 Key: CB-9396
>                 URL: https://issues.apache.org/jira/browse/CB-9396
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Contacts
>         Environment: iphone4/s iOS
>            Reporter: Edd A
>              Labels: ios, triaged
>
> We are using phonegap and angularjs on our mobile app.. We are currently 
> getting phone contacts and it is crashing on iphone4/s only. It is working on 
> android and iphone 6. I can't seem to find where the error is.
> Here is the code..
> {noformat}
> module.controller('someControllerName', ['$scope', '$http', function ($scope, 
> $http) {
>     // find all contacts with 'Bob' in any name field
>     var options = new ContactFindOptions();
>     options.filter = "";
>     options.multiple = true;
>     var fields = ["displayName", "name"];
>     navigator.contacts.find(fields, loadAllContacts, onError, options);
>     $scope.viewContact = function (contact) {
>         buxMainNav.pushPage("contact_details.html",
>             { "animation": "slide", phone_contact: contact }
>         );
>     };
>     $scope.$watch('searchContacts', function (data) {
>         if (data != undefined) {
>             // find all contacts with 'Bob' in any name field
>             var options = new ContactFindOptions();
>             options.filter = data;
>             options.multiple = true;
>             var fields = ["displayName", "name"];
>             navigator.contacts.find(fields, loadAllContacts, onError, 
> options);
>             $scope.viewContact = function (contact) {
>                 buxMainNav.pushPage("contact_details.html",
>                     { "animation": "slide", phone_contact: contact }
>                 );
>             };
>         }
>     });
> }]);
> function loadAllContacts(contacts) {
>     var cSort = function (a, b)
>     { aName = a.name.givenName; bName = b.name.givenName; return aName < 
> bName ? -1 : (aName == bName ? 0 : 1); }
>     ;
>     var scope = 
> angular.element(document.getElementById("contacts-controller")).scope();
>     scope.nocontactsresults = "";
>     scope.$apply(function () {
>         contacts = contacts.sort(cSort);
>         scope.phoneContacts = contacts;
>         if (scope.phoneContacts.length < 1)
>             { scope.nocontactsresults = "No Results"; }
>         else
>             { scope.nocontactsresults = ""; }
>     });
> };
> function onError(contactError) {
>     ons.notification.alert(
>     { message: "Unable to access phonebook contacts.", title: "Contacts" }
>     );
> };
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to