TheCocoaProject / cordova-plugin-nativestorage

Cordova plugin: Native storage of variables in Android, iOS and Windows
http://thecocoaproject.github.io/
Apache License 2.0
292 stars 106 forks source link

Supplied parameters do not match any signature of call target #55

Closed gigocabrera closed 8 years ago

gigocabrera commented 8 years ago

I have an ionic2 app with NativeStorage plugin and I'm following the instructions for storing values as shown below. However, I get a Typescript error and it won't let me build the app

import { NativeStorage } from 'ionic-native';

setUsername(storageemail) {
  NativeStorage.setItem('storageemail',storageemail, this.setSuccess(), this.setError());
}
setSuccess(obj) {
  console.log(obj.name);
};
setError(error) {
  console.log(error.code);
  if (error.exception !== "") console.log(error.exception);
};

Error

[ts] Supplied parameters do not match any signature of call target.
(method) NativeStorage.setItem(reference: string, value: any): Promise<any>
Stores a value

Details

Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.13 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.46 ios-deploy version: Not installed ios-sim version: 4.1.1 OS: OS X El Capitan Node Version: v6.3.1 Xcode version: Xcode 8.1 Build version 8B62

Package.json

{
  "name": "MoneyLeash",
  "author": "Luis Cabrera",
  "homepage": "http://moneyleash.com/",
  "private": true,
  "repository": {
    "type": "git",
    "url": "https://github.com/gigocabrera/MoneyLeash2"
  },
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.6",
    "angularfire2": "^2.0.0-beta.6",
    "firebase": "3.3.0",
    "font-awesome": "^4.6.3",
    "ionic-angular": "^2.0.0-rc.3",
    "ionic-native": "^2.2.7",
    "ionicons": "3.0.0",
    "moment": "^2.15.1",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.46",
    "@types/request": "0.0.30",
    "typescript": "^2.0.9"
  },
  "description": "Don't let your money run wild. Keep it on a leash!",
  "cordovaPlugins": [
    "cordoba-plugin-device",
    "cordoba-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "config": {
    "ionic_copy": "./scripts/copy-custom-libs.js"
  }
}
GillesC commented 8 years ago

You should use the Ionic2 API which is described here.

gigocabrera commented 8 years ago

@GillesC thank you for pointing that out. It's working as expected now. My bad :stuck_out_tongue_winking_eye: