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

@spoonconsulting/cordova-plugin-extra-events

v1.0.0

Published

Cordova Plugin Extra Events

Downloads

317

Readme

Installation

cordova plugin add @spoonconsulting/cordova-plugin-extra-events

Tested platforms: Android 8+, iOS 11+

Usage

This plugin provides access to extra lifecycle events that are useful for saving data before your app quits. This allows you to mostly work around the following issues with cordova:

  • iOS: The onPause event is never fired if the user activates the app switcher, then swipes up to kill the app.
  • Android: The onPause event is never fired if the user actives the "recent apps" switcher, then swipes to kill the app.
constructor() {
    this.unregister = window.plugins.ExtraEvents.registerForEvents(this.onPluginEvent, (err) => {
        console.error(err);
    });
}

private onPluginEvent(e: CdvExtraEvent) {
    // Save our state when the app starts to go to the background.
    switch (e.eventName) {
        case 'android_onWindowFocusChanged':
            if (!e.hasFocus) {
                this.saveState();
            }
            break;
        case 'iOS_appWillResignActive':
            this.saveState();
            break;
    }
}

API and Events

window.plugins.ExtraEvents.registerForEvents(eventCallback, error?)

Registers a callback function to receive events. Returns an unregister function. Can be called with the following events:

android_onWindowFocusChanged (Android only)

Emitted when the main activity gains or loses focus. This happens when your app launches, goes into the background, is interrupted by a dialog or alert, when the user opens the system UI, etc. See the android docs for more info: https://developer.android.com/reference/android/app/Activity.html#onWindowFocusChanged(boolean).

Warning If the user actives the app switcher quickly and immediately kills your app, this event might not have time to fire. Also, if the user kills the app and your callback is taking a long time to run, Android might kill it, the same way that this happens with the native onStop and onDestroy methods.

{
    eventName: 'android_onWindowFocusChanged',
    hasFocus: boolean,
}

iOS_appWillResignActive (iOS only)

Emitted when the app starts going to the background or when the app switcher is triggered. See the native docs for more info: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622950-applicationwillresignactive?language=objc.

{
    eventName: 'iOS_appWillResignActive',
}

iOS_appWillEnterForeground (iOS only)

Emitted as the app transitions from background to foreground. See the native docs for more info: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623076-applicationwillenterforeground?language=objc.

{
    eventName: 'iOS_appWillEnterForeground',
}