danilobatistaqueiroz / screen-on-off-detect

capacitor plugin to detect screen on and off events

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

you need to use npm

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...

ScreenOffDetect

Detect screen off detect event in the device

Install

pnpm build
pnpm install screenoffdetect
npx cap sync

API

addListener('screenOnOff', ...)

addListener(eventName: 'screenOnOff', listener: OnOffListener) => any
Param Type
eventName 'screenOnOff'
listener OnOffListener

Returns: any


Interfaces

ScreenOnOffState

Prop Type
value string

PluginListenerHandle

Prop Type
remove () => any

Type Aliases

OnOffListener

(state: ScreenOnOffState): void

USING IN AN IONIC APP

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

About

capacitor plugin to detect screen on and off events


Languages

Language:JavaScript 34.2%Language:Java 23.1%Language:Swift 11.3%Language:TypeScript 9.5%Language:HTML 8.9%Language:Ruby 7.5%Language:Objective-C 5.2%Language:CSS 0.3%