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-foreground-service

v1.1.3

Published

Foreground service with ongoing notification.

Downloads

1,930

Readme

cordova-plugin-foreground-service npm version

NOTE: This plugin does not on its own allow the user to execute javascript while the app is in the background. This must be accompanied by another plugin that will create a background process that will give the application background cycles. This plugin mainly exists to solve the problem outlined here. An app will have restricted background processing if it is not considered a "foreground app" for android API 26+ and will prevent background pluggins from functioning properly. With this plugin your application will be a foreground app and let your background services run properly. This plugin may also help with android doze where an application may not run in the background unless it also has a foreground process. Do not expect this plugin on its own to allow your app to execute javascript while in the background.


This plugin allows for android devices to continue running services in the background, using a foreground ongoing notification. This is targeted towards use with plugins such as 'cordova-geolocation' that will not run while the app is in the background on android API 26+.


Requirements

  • cordova-android version >= 7.0.0
  • android-sdk api >= 26

NOTE: Using cordova version >= 8.0.0 is recommended.


Setup and Usage

Install

cordova plugin add cordova-plugin-foreground-service

#or

cordova plugin add https://github.com/DavidBriglio/cordova-plugin-foreground-service

Start Method

To enable the foreground service, call the start method:

cordova.plugins.foregroundService.start('Notification Title', 'Notification Text', 'drawable-icon-name', [notification importance], [notification id]);

// High priority with notification id 10
// ('myicon.png' is in the 'res/drawable' folder)
cordova.plugins.foregroundService.start('GPS Running', 'Background Service', 'myicon', 3, 10);

// Notification id is optional
cordova.plugins.foregroundService.start('GPS Running', 'Background Service', 'myicon', 3);

// Notification importance is optional, the default is 1 - Low (no sound or vibration)
cordova.plugins.foregroundService.start('GPS Running', 'Background Service', 'myicon');

// Icon is optional, but will use a 'star' icon as the default
cordova.plugins.foregroundService.start('GPS Running', 'Background Service');

Stop Method

To disable the foreground service, call the stop method:

cordova.plugins.foregroundService.stop();

Parameters

Icon

The drawable icon can be any drawable image that exists in the resource folder. This means you must copy the icon you want to use into the platforms/android/app/src/main/res/drawable folder set. If no icon can be found using the icon name parameter, a default star icon will be used.

NOTE: The normal android drawable (R.drawable) icons are not available for use as icons. You cannot reference these icons through the start icon parameter. Include your icon manually in the folders mentioned above.

Notification ID

The notification id is a customizable integer that is used to reference the notification that will be launched. This is customizable to avoid conflicting with any other notifications. If this is not included, a default id will be used.

Notification Importance

Notification importance dictates how the notification is initially presented:

Value | Importance | Description --- | --- | --- 1|IMPORTANCE_LOW|Does not make a sound or heads-up display. (Default) 2|IMPORTANCE_DEFAULT|Makes a sound, but no heads-up display. 3|IMPORTANCE_HIGH|Makes a sound and heads-up display.


Questions?

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


License

MIT - Please see the LICENSE file for details.


David Briglio (2018)