0.0.1 • Published 6 years ago
@boosten/capacitor-keep-awake v0.0.1
capacitor-keep-awake
Prevent your screen from getting some sleep!
Installation
npm i @boosten/capacitor-keep-awakeConfiguration
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.
0.0.1
6 years ago