Giter Site home page Giter Site logo

nativescript-community / insomnia Goto Github PK

View Code? Open in Web Editor NEW
40.0 17.0 11.0 695 KB

:sleepy: NativeScript plugin to keep the device awake (not dim the screen, lock, etc)

JavaScript 83.09% TypeScript 16.91%
nativescript nativescript-plugin insomnia awake screen dimming

insomnia's Introduction

NativeScript Insomnia

๐Ÿ’ก Plugin version 2.0.0+ is compatible with NativeScript 7+. If you need to target older NativeScript versions, please stick to plugin version 1.2.3.

Demo app (Angular)

This plugin is part of the plugin showcase app I built using Angular.

Installation

Run the following command from the root of your project:

tns plugin add @nativescript-community/insomnia

Usage

To use this plugin you must first require() it:

JavaScript

var insomnia = require("@nativescript-community/insomnia");

TypeScript

You could do the same as in JS, but this looks fancier, right?

import { keepAwake, allowSleepAgain } from "@nativescript-community/insomnia";

keepAwake

  insomnia.keepAwake().then(function() {
      console.log("Insomnia is active");
  })

allowSleepAgain

  insomnia.allowSleepAgain().then(function() {
      console.log("Insomnia is inactive, good night!");
  })

insomnia's People

Contributors

andres2050 avatar bradmartin avatar eddyverbruggen avatar farfromrefug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

insomnia's Issues

Can not make it work on a Nativescript-Vue project

Hi!
I'm trying to use this plugin within a nativescript-vue project but I aways get this error when keepAwake is called:

TypeError: Cannot read property 'getWindow' of undefined'

Actually, I'm trying to run on android platform. Nativescript version is 4.1.

Thanks!

App sleeping if modal is open

Hi,
If user is looking on a modal without touching the phone,
the phone is dimming and go to sleep..

I tried to add "keepAwake" when opening modal but no help..

Any suggestions?

Thanks

IOS application crash in Xcode after using insomnia.keepAwake

I am working on Nativescript 6 + Javascript application and I have used insomnia in my code but my application is getting crash due to 'insomnia'.

Here is further error when my application is crash due to insomnia
And my IOS version is 13.1.

2019-11-28 01:03:20.954926+0530 salesrepmobile[19942:14434690] *** Assertion failure in 
 - [FBSSerialQueue assertOnQueue], 
/BuildRoot/Library/Caches/com.apple.xbs/Sources/FrontBoardServices_Sim/FrontBoard- 
 619.2/FrontBoardServices/FBSSerialQueue.m:98
(lldb) 

Please help me. I am really stuck on this.

Webpack support

Hey Eddy, looks like webpack support was added to package.json by removing .js but doesnt look like this was released to NPM.

Still Sleeping after period of time

@EddyVerbruggen

I know why you added the code to check for foreground activity to keepawake or sleep when the app is not active but for me this defeats the whole purpose of the plugin. Can we either revert back to the older version or add a flag to disable this activity check?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.