GOSCHEN
GOSCHEN

Reputation: 454

Saving a mobile number to WP contacts wird cordova contacts plugin

I iterate through an array of a few mobile numbers here:

    for (var i = 0; i < kondaten.length; i++) {
        if (kondaten[i].typ == "work") {
            phoneNumbers[0] = new ContactField('work', kondaten[i].telefonnummer, null);
        } else if (kondaten[i].typ == "private") {
            phoneNumbers[1] = new ContactField('home', kondaten[i].telefonnummer, null);
        } else if (kondaten[i].typ == "mobile") {
           phoneNumbers[2] = new ContactField('mobile', kondaten[i].telefonnummer, null);
        }
    }

Now my problem is: If my app reaches the mobile number, the contact won't be saved. But, if I comment out this line:

phoneNumbers[2] = new ContactField('mobile', kondaten[i].telefonnummer, null);

, everything works fine... Is there an unknown type for mobile numbers or is it just impossible to save one?

In the cordova-plugin-contacts API, it is referenced that you can only store one number for each type. Plugin API

On this page: Dzone reference, they use the mobile type, and it seems to work properly.

Thanks in advance!

Upvotes: 1

Views: 77

Answers (1)

GOSCHEN
GOSCHEN

Reputation: 454

Everything works fine...

The issue was, that sometimes a contact did not have a private number, so the phoneNumbers[] had no [1] index.

The solution was to push every number, into the array.

Upvotes: 1

Related Questions