capacitor-keep-awake
![npm version](https://badge.fury.io/js/%40boosten%2Fcapacitor-keep-awake.svg)
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);
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {
{
add(KeepAwake.class);
}
});
}
}
Credits
Capacitor version of the plugin: cordova insommia.