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-background-app

v2.0.2

Published

The purpose of this plugin is to enable notifications, alarms, etc to re-start your app and fire callbacks without the app causing any visual cues to the user. In essense, it allows starting an app as an Android service, but does so without the use of an

Downloads

13

Readme

Start an App Without Showing the Activity

The purpose of this plugin is to enable notifications, alarms, etc to re-start your app and fire callbacks without the app causing any visual cues to the user. In essense, it allows starting an app as an Android service, but does so without the use of an actual service.

Status

Works on iOS and Android.

iOS values for resumeType limited to: '', 'launch', 'normal', 'normal-launch'

Usage

To see it in action, try the example app.

For how to create your own plugin that uses it, look at cordova-plugin-chrome-apps-notifications or cordova-plugin-chrome-apps-alarms

cordova.backgroundapp.resumeType (string)

After the deviceready event, this will either be:

  • '' - When started as a service.
  • 'launch' - When started normally.

After a resume event, this will be one of:

  • 'normal' - Triggered by an external intent (launcher / task switcher). App was running normally, but had been backgrounded.
  • 'normal-launch' - Triggered by an external intent (launcher / task switcher). App was running as a service.
  • 'programmatic' - Triggered by a call to BackgroundActivity.launchForeground(). App was running normally, but had been backgrounded.
  • 'programmatic-launch' - Triggered by a call to `BackgroundActivity. App was running as a service.

The normal way to use this plugin:

document.addEventListener("deviceready", function() {
    if (cordova.backgroundapp.resumeType == 'launch') {
        renderUi();
    }
}, false);
document.addEventListener("resume", function() {
    if (cordova.backgroundapp.resumeType == 'normal-launch') {
        renderUi();
    } else if (cordova.backgroundapp.resumeType == 'programmatic-launch') {
        // You launched programatically (through cordova.backgroundapp.show() perhaps)
        // so you should have already called renderUi() from where you called .show().
    }
}, false);

cordova.backgroundapp.show()

Brings the app to the foreground. E.g. Call this in response to a user clicking on a notification.

This symbol will be null on iOS, since iOS has not yet implemented this functionality.

Implementation Details

The goal is ultimately to be able to run the app in an Android service, but because many plugins utilize CordovaInterface.getActivity(), a background Activity rather than a Service is more viable.

  • Uses gradle build rule to remove your default <intent-filter>
  • Uses a BackgroundLauncherActivity to recieve launch intent and start your main activity.
  • If you are an already shipping app, you should use an <activity-alias> to make your previous main activity point to BackgroundLauncherActivity, and then rename your main activity to not conflict with the alias. This is so that launcher shortcuts continue to function correctly.

Known Issues

  • When the app goes from not running -> running in background, if you are currently in the task switcher, the task switcher will close.
  • On Lollipop, backgrounded app shows in recents list when no other recents exists (fixed in MR1)

Release Notes

2.0.1 (May 13, 2015)

  • Fix cordova.backgroundapp.resumeType being 'launch' when running in background on Android
  • Added sample app to git repo

2.0.0 (April 29, 2015)

  • Introduced cordova.backgroundapp.resumeType and cordova.backgroundapp.show()
  • Rewrote Android implementation to not require translucent theme
  • Minimal iOS support added (basic resumeType values only)

1.0.0 (March 2015)

  • Initial release