danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.41k stars 2.43k forks source link

ionic-native/device-accounts: Not returning results #1933

Closed adetoola closed 6 years ago

adetoola commented 7 years ago

I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request

Current behavior: Device-Accounts is not working properly. It seems promises are not working as both then and the catch block are not returning any results for get(), getEmail(), getEmails().

Expected behavior: As per documentation, those function should return a promise with the email accounts registered on the device.

Steps to reproduce: Simply follow the installation steps for the plugin. Insert relevant initialisation code into a platform.ready() block Connect an android device and run: ionic cordova run android -lcs --debug --device Then check console for outputs

Related code:

constructor(public navCtrl: NavController, public navParams: NavParams, private deviceAccounts: DeviceAccounts, private platform: Platform) {
    this.platform.ready().then(() => {
      console.log('Platform.ready have been called!');

      //Check if deviceAccounts is being called.
      const dA = this.deviceAccounts;
      console.dir(dA); // Yes, I am being called. The prove is in the console output

      this.deviceAccounts.getEmail()
        .then(account => console.log('Account' + account)) // Guy, double your hustle, not working.
        .catch(error => console.error(error)); // So, sorry for you. Not working.

      this.deviceAccounts.get()
        .then(accounts => console.dir(accounts)) // No output. DOA
        .catch(error => console.error(error)); // No output
    });
  }

Other information: Device: Samsung Galaxy Tab 4(SM-T531) Android version: 5.0.2

package.json info:

{
    "name": "",
    "version": "",
    "author": "",
    "homepage": "",
    "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/animations": "^4.1.3",
        "@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/android-permissions": "^4.2.0",
        "@ionic-native/app-minimize": "^4.2.0",
        "@ionic-native/camera": "^4.1.0",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/device-accounts": "^4.2.0",
        "@ionic-native/geolocation": "^4.1.0",
        "@ionic-native/native-storage": "^4.1.0",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "2.0.1",
        "com.danielsogl.cordova.deviceaccounts": "~1.0.0",
        "cordova-android": "^6.2.3",
        "cordova-device-accounts": "^1.0.0",
        "cordova-plugin-android-permissions": "^1.0.0",
        "cordova-plugin-appminimize": "^1.0.0",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.1.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-geolocation": "^2.4.3",
        "cordova-plugin-nativestorage": "^2.2.2",
        "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",
        "ng2-validation": "^4.2.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.1.3",
        "typescript": "2.3.4"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-nativestorage": {},
            "cordova-plugin-geolocation": {},
            "cordova-plugin-compat": {},
            "cordova-plugin-camera": {},
            "com.danielsogl.cordova.deviceaccounts": {},
            "cordova-plugin-appminimize": {},
            "cordova-plugin-android-permissions": {}
        },
        "platforms": [
            "android"
        ]
    }
}

Ionic Info:

cli packages: (C:\Users\HP\AppData\Roaming\nvm\v8.0.0\node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

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:

    Android SDK Tools : 25.1.3
    Node              : v8.0.0
    npm               : 5.3.0
    OS                : Windows 10
mariopacio commented 6 years ago

Same problem here, with ionic 2, galaxy s7 edge

ihadeed commented 6 years ago

Instead of this:

      this.deviceAccounts.getEmail()
        .then(account => console.log('Account' + account)) // Guy, double your hustle, not working.
        .catch(error => console.error(error)); // So, sorry for you. Not working.

      this.deviceAccounts.get()
        .then(accounts => console.dir(accounts)) // No output. DOA
        .catch(error => console.error(error)); // No output

Can you try this:

      DeviceAccounts.getPlugin().getEmail(
        account => console.log('Account' + account),
        error => console.error(error));

      DeviceAccounts.getPlugin().get(
       accounts => console.dir(accounts),
       error => console.error(error));

If it doesn't work, then this is an issue with the plugin & not Ionic Native.

UlisesCeca commented 6 years ago

Hello. I wanted to try this plug-in out today too but this is happening to me now. Nothing is showing in the promise or in its catch. How can I solve this?

Thanks.