inpm init @capacitor/plugin@latest
npx: installed 26 in 8.246s
✔ What should be the npm package of your plugin?
… ScreenOffDetect
✔ What directory should be used for your plugin?
… ScreenOffDetect
✔ What should be the Package ID for your plugin?
Package IDs are unique identifiers used in apps and plugins. For plugins,
they're used as a Java namespace. They must be in reverse domain name
notation, generally representing a domain name that you or your company owns.
… br.labs.screenoffdetect
✔ What should be the class name for your plugin?
… ScreenOffDetectPlugin
✔ What is the repository URL for your plugin?
… https://github.com/danilobatistaqueiroz/screen-off-detect-plugin
✔ (optional) Who is the author of this plugin?
… Danilo Batista de Queiroz
✔ What license should be used for your plugin?
› MIT
✔ Enter a short description of plugin features.
… list the ScreenOffDetect in the device
Installing dependencies. Please wait...
Detect screen off detect event in the device
pnpm build
pnpm install screenoffdetect
npx cap sync
addListener(eventName: 'screenOnOff', listener: OnOffListener) => any
Param | Type |
---|---|
eventName |
'screenOnOff' |
listener |
OnOffListener |
Returns: any
Prop | Type |
---|---|
value |
string |
Prop | Type |
---|---|
remove |
() => any |
(state: ScreenOnOffState): void
package.json
"dependencies": {
"screen-on-off-detect": "link:/......./plugins/screen-on-off-detect",
}
home.component.ts
import { ScreenOnOffDetect } from 'screen-on-off-detect';
async ngOnInit() {
ScreenOnOffDetect.addListener('screenOnOff', ({value}) => {
console.log(`Screen is now ${value}`);
});
}