Ionic native contacts are not working?


#1

Can’t resolve all parameters for ContactField: (?, ?, ?).

I have this issue when i am working with contacts in ionic3


#2

What is your ionic info output?
What exactly did you implement? What is your code?


#3

I tried to save the contact list in my contacts.but it cause an issue Cant resolve all parameters for CantactField

Ionic info output:

cli packages: (C:\Users\Admin\sample_phoneCall\node_modules)

@ionic/cli-plugin-cordova       : 1.6.1
@ionic/cli-plugin-ionic-angular : 1.4.0
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v8.1.4
OS   : Windows 10
npm  : 5.0.3

Here is My code:

 contact()
    {
      let contact: Contact = this.contacts.create();
      contact.name = new ContactName(null, 'Smith', 'John');
      contact.phoneNumbers = [new ContactField('mobile', '6471234567')];
      contact.save().then(
        () => console.log('Contact saved!', contact),
        (error: any) => console.error('Error saving contact.', error)
      );
    }

#4

Can’t resolve all parameters for ContactField: (?, ?, ?).

According to what you’re giving us, it seems like your missing a third obligatory field.


#5

Problem is he is using the example from the docs here :wink:


#6

Definition of ContactField is here:

Maybe try adding a third parameter “false”? Although this should not be needed really…


#7

whoooops. Didn’t notice that. I don’t think the third param is the issue here (@Sujan12 already showed us actually).

Seems to be lacking any providing at all since none of the params are resolved. Did you installed the npm package and also correctly include the imports at the top of your file @sabarinathen? Also added the plugin to your app.module?

These imports:

import { Contacts, Contact, ContactField, ContactName } from '@ionic-native/contacts';


#8

I imported already, if i am not import it was not accepted the parameter and also added in app.module file.
also tried as third parameter as false …same issue again


#9

And are you sure you’ve installed the npm file? Could you post the contents of package.json here?


#10

Just noticed something:

The code you posted is not using ' ... ' around the values but ‘ ... ’. Is this your real code?


#11

@luukschoen : its my package.json file

@Sujan12:if you want i ll show the screen shot of my code.otherwise you just copy the code and then paste it in command check preview it will show the ‘…’ as similar to that ‘ … ’…


#12

Could you still just copy and paste the content of the entire package.json? I’m only seeing part of it and it’s not really nice for screenreaders and stuff to post pictures (regardless the quotes). I’m curious to see your dependencies, I definitely believe the plugin is in the right place.


#13

I copied your code to my VS Code, I have a project that does Ionic Native Contacts stuff, and the code didn’t work - that’s why I was asking.

Edit: Figure out that editing your post and marking the code as code (by using the </> button above the post) fixed the issue. So not relevant to your actual problem.


#14
{
    "name": "sample_phoneCall",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/call-number": "^4.1.0",
        "@ionic-native/contacts": "^4.1.0",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "2.0.1",
        "call-number": "^1.0.1",
        "cordova-android": "^6.2.3",
        "cordova-plugin-compat": "^1.0.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-contacts": "^2.3.1",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "ionic-angular": "3.6.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "mx.ferreyra.callnumber": "~0.0.2",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.1.3",
        "@ionic/cli-plugin-cordova": "1.6.1",
        "@ionic/cli-plugin-ionic-angular": "1.4.0",
        "ionic": "3.7.0",
        "typescript": "2.3.4"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "mx.ferreyra.callnumber": {},
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordov-plugin-contacts": {}
        },
        "platforms": [
            "android"
        ]
    }
}

#15

I have the exact code you posted in my contacts demo app:

https://github.com/janpio/ionic-native-contacts/commits/master

See the last commit. I tested on a Nexus 5 via ionic cordova run android.


#16

This is missing an a. Maybe the plugin is not correctly installed because of that.


#17

That’s curious. What does ionic cordova plugin list output ? I also see a difference in versions between ionic-native/core and the plugins later installed, it’s best if you keep them both up to date.


#18

once again i tried it removing the contact plugin and try again again the same issue…


#19

Download my repo, run npm install, run it on your device to check if it works for you.


#20

It wil show the white screen running in android device