npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-android-utility

v1.3.1

Published

Cordova Android general utility plugin.

Downloads

164

Readme

Cordova Android Utility Plugin npm version

This plugin is built as a general tool utility to perform relatively small tasks on the native android side.


Contents

Setup

cordova plugin add cordova-plugin-android-utility

# or

cordova plugin add https://github.com/DavidBriglio/cordova-plugin-android-utility

Methods

getVersionInfo

Usage: cordova.plugins.android.utility.getVersionInfo()

This method will return information on the android version.

Returns Promise with:

| Index | Type | |-------|------| | sdk | Integer | | baseOs | String | | codeName | String | | incremental | String | | previewSdk | Integer | | release | String | | securityPatch | String |

Example Usage:

cordova.plugins.android.utility.getVersionInfo()
  .then(info => {
    // Show the android official release number and the sdk number
    console.log(`Android ${info.release} (SDK ${info.sdk})`)
  })
  .catch(message => console.log('Error: ' + message))

getNotificationChannels

Android 26+

Usage: cordova.plugins.android.utility.getNotificationChannels()

This method will return a promise with an array of notification channel id strings.

Example Usage:

cordova.plugins.android.utility.getNotificationChannels()
  .then(channels => {
    // List all channels
    for (let i in channels) {
      console.log(`Channel ${i}: ${channels[i]}`)
    }
  })
  .catch(message => console.log('Error: ' + message))

getNotificationChannel

Android 26+

Usage: cordova.plugins.android.utility.getNotificationChannel([string: channel id])

This method will return a promise with all information about the specified channel id.

Android Documentation

Returns Promise with: | Index | Type | Description | |-------|------|-------------| | canBypassDnd | Boolean | True if the notification bypasses do not disturb. | | canShowBadge | Boolean | True if the notification will show a badge when active. | | description | String | Description of the channel. | | group | String | Channel group. | | id | String | Channel ID. | | importance | Integer | Integer representing channel importance. Refer to android documentation for value representations. | | lightColour | Integer | Integer representation of the light colour shown when showsLights is true. | | lockscreenVisibility | Integer | Integer value representing visibility of the notification on the lock screen. Refer to the android documentation for value representations. | | name | String | Name of the channel. | | sound | String | URI of the sound being used. | | vibrationPattern | Array | Vibration pattern array. | | showsLights | Boolean | Can show LED light when notification is active. | | vibration | Boolean | True if notification will cause a vibration. | | summary | String | The toString method result of the channel. |

Example Usage:

cordova.plugins.android.utility.getNotificationChannel('TEST_CHANNEL_1')
  .then(channel => {
    // Show some of the channel information
    console.log('This channel is: ' + channel.name)
    console.log('This channel has vibration: ' + (channel.vibration ? 'Enabled' : 'Disabled'))
    console.log('This channel uses the sound: ' + channel.sound)
  })
  .catch(message => console.log('Error: ' + message))

getNotificationSettings

Usage: cordova.plugins.android.utility.getNotificationSettings()

Obtain the base notification settings for the application. Use this for global settings and with API 25-.

Returns Promise with:

| Index | Type | Description | |-------|------|-------------| | enabled | Boolean | True if notifications are enabled for the app. | | importance | Integer | Integer value representing importance of notifications in the app. (API 25-) |

cordova.plugins.android.utility.getNotificationSettings()
  .then(settings => {
    // Show the global notification settings for the app
    console.log('Notifications are: ' + (settings.enabled ? 'Enabled' : 'Disabled'))
    console.log('Importance Level: ' + settings.importance)
  })
  .catch(message => console.log('Error: ' + message))

openNotificationSettings

Usage: cordova.plugins.android.utility.openNotificationSettings()

Open the Android OS notification settings page corresponding to the current application. This method takes no parameters and does not return any values.

getSimInfo

Usage: cordova.plugins.android.utility.getSimInfo()

Obtain the sim card information including the device phone number, imei and sim serial number.

| Index | Permission Required | |-------|---------------------| | phoneNumber | android.permission.READ_PHONE_STATE | | imei | android.permission.READ_PRIVILEGED_PHONE_STATE | | serial | android.permission.READ_PRIVILEGED_PHONE_STATE |

// NOTE: Proper permissions must be requested first
cordova.plugins.android.utility.getSimInfo()
  .then(info => console.log(`Phone Number: ${info.phoneNumber}, IMEI: ${info.imei}, Serial#: ${info.serial}`))
  .catch(message => console.log(`Error Message: ${message}`))

Questions?

Please feel free to open an issue or make a pull request!


License

MIT - Please see the LICENSE file for details.


David Briglio (2020)