2.0.8 • Published 5 years ago

cordova-device-accounts-v2 v2.0.8

Weekly downloads
40
License
Apache-2.0
Repository
github
Last release
5 years ago

Cordova Device Accounts v2 Plugin

Downloads Maintainability Known Vulnerabilities License

Cordova plugin to get the device accounts on Android.

Install

If you're using Ionic you can use the following commands:

ionic cordova plugin add cordova-device-accounts-v2 --save
npm install @ionic-native/device-accounts

Note: This is the official maintained repository for the "Device Account" plugin, view the Ionic documentation Here.

Otherwise use the following command:

cordova plugin add cordova-device-accounts-v2 --save

Required Permissions

Requires the following permissions:

  • android.permission.GET_ACCOUNTS
  • android.permission.GET_ACCOUNTS_PRIVILEGED
import { AndroidPermissions } from '@ionic-native/android-permissions';

constructor(private androidPermissions: AndroidPermissions) { }

...

return this.androidPermissions.requestPermissions(
  [
    this.androidPermissions.PERMISSION.GET_ACCOUNTS,
    this.androidPermissions.PERMISSION.GET_ACCOUNTS_PRIVILEGED
  ])
  .then(permission => console.log('Permissions Granted: ' + JSON.stringify(permission)))
  .catch(error => console.error(error));

Methods

  • DeviceAccounts.get(onSuccess, onFail) : get all accounts registered on device
  • DeviceAccounts.getByType(type, onSuccess, onFail) : get all accounts registered on device for requested type
  • DeviceAccounts.getEmails(onSuccess, onFail) : get all emails registered on device (accounts with 'com.google' type)
  • DeviceAccounts.getEmail(onSuccess, onFail) : get the first email registered on device or undefined
  • DeviceAccounts.getPermissions(onSuccess, onFail) : get all emails and request permissions from user.

Note: since Android 8.0.0+ device accounts are not visible to the application. Users must grant access to email accounts they wish to be visible to the application.

Example

import { DeviceAccounts } from '@ionic-native/device-accounts';

constructor(private deviceAccounts: DeviceAccounts) { }

...

this.deviceAccounts.get()
  .then(accounts => console.log(accounts))
  .catch(error => console.error(error));

A demo Ionic application can be viewed to see a working implementation of this plugin Here.

Compatibility

The following versions are compatible with this plugin:

  • Cordova 3.3 +
  • Android 4.4 +
2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago