Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Prevent your Capacitor app from getting some sleep!

License

Notifications You must be signed in to change notification settings

RangerRick/keep-awake

 
 

Repository files navigation


keep-awake

@capacitor-community/keep-awake

Capacitor community plugin to prevent your screen from getting some sleep!


Maintainers

Maintainer GitHub Social
Kevin Boosten boosten @Boostuh1

Installation

npm i @capacitor-community/keep-awake

Configuration

iOS

No extra steps required 🙂.

Android

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

import com.getcapacitor.community.keepawake.KeepAwake;

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);
          }
        }
      );
  }
}

Usage

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

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

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

Credits

Capacitor version of the plugin: cordova insommia.

About

Prevent your Capacitor app from getting some sleep!

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 33.9%
  • Swift 24.6%
  • Ruby 12.7%
  • TypeScript 12.0%
  • Objective-C 9.6%
  • JavaScript 7.2%