This package has been deprecated

Author message:

This package has been moved to @capacitor-community/keep-awake

@boosten/capacitor-keep-awake
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

capacitor-keep-awake

npm version

Prevent your screen from getting some sleep!

Installation

npm i @boosten/capacitor-keep-awake

Configuration

Example

Check out the example repo: capacitor-keep-awake-example

import { Plugins } from '@capacitor/core';

@Component({
  template: `
    <button (click)="keepAwake()">keep awake!</button>
    <button (click)="allowSleep()">let me sleep!</button>
  `
})
export class SignupComponent {
  async keepAwake() {
    await Plugins.KeepAwake.keepAwake();
  }

  async allowSleep() {
    await Plugins.KeepAwake.allowSleep();
  }
}

Web

This functionality is not applicable to the browser.

iOS

No extra steps required 🙂.

Android

You have to register your plugin in your app main activity. See official Capacitor docs

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {
      {
        // Additional plugins you've installed go here
        // Ex: add(TotallyAwesomePlugin.class);
        add(KeepAwake.class);
      }
    });
  }
}

Credits

Capacitor version of the plugin: cordova insommia.

Readme

Keywords

Package Sidebar

Install

npm i @boosten/capacitor-keep-awake

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

1.68 MB

Total Files

174

Last publish

Collaborators

  • boosten