All Projects → ochococo → Insomnia

ochococo / Insomnia

Licence: mit
🌃 How to prevent screen lock on my application?

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Insomnia

Siriwave
The Apple® Siri wave-form replicated in a JS library.
Stars: ✭ 1,186 (+1110.2%)
Mutual labels:  apple
Swiftautolayout
Write constraints in a concise, expressive, Swifty way.
Stars: ✭ 83 (-15.31%)
Mutual labels:  apple
Daily Coding Problem
Series of the problem 💯 and solution ✅ asked by Daily Coding problem👨‍🎓 website.
Stars: ✭ 90 (-8.16%)
Mutual labels:  apple
Doric
Protocol oriented, type safe, scalable design system foundation swift framework for iOS.
Stars: ✭ 75 (-23.47%)
Mutual labels:  apple
Stayswifty
This is the place where iOS developer can get the most recent and helpful information. Have fun!
Stars: ✭ 82 (-16.33%)
Mutual labels:  apple
Beagle Im
XMPP client for macOS based on TigaseSwift XMPP library
Stars: ✭ 86 (-12.24%)
Mutual labels:  apple
Free Sidecar
Enable Sidecar on Unsupported iPads and Macs running iPadOS 13 and macOS Catalina
Stars: ✭ 1,159 (+1082.65%)
Mutual labels:  apple
Xchain
A cross compiler toolchain targeting macOS/iOS/etc.
Stars: ✭ 95 (-3.06%)
Mutual labels:  apple
Micromdm
Mobile Device Management server
Stars: ✭ 1,238 (+1163.27%)
Mutual labels:  apple
Shortcuts Js
A JavaScript iOS 12 Shortcuts creator
Stars: ✭ 1,278 (+1204.08%)
Mutual labels:  apple
Docker Icloudpd
An Alpine Linux 3.13 container for the iCloud Photos Downloader command line utility
Stars: ✭ 76 (-22.45%)
Mutual labels:  apple
Popcorntimetv
Popcorn Time for Apple TV 4, iPhone and iPad
Stars: ✭ 1,216 (+1140.82%)
Mutual labels:  apple
Night Shift On Unsupported Macs
Enable Night Shift on older Unsupported Macs
Stars: ✭ 86 (-12.24%)
Mutual labels:  apple
Zcash Apple
Zcash for Apple platforms
Stars: ✭ 75 (-23.47%)
Mutual labels:  apple
One Vue
仿韩寒「ONE · 一个」,基于vue2.0+混合式开发的一款跨终端、高性能、用户体验高的移动端App! 学习Vue的同学可以看下,感谢 Star 和 Fork!!
Stars: ✭ 93 (-5.1%)
Mutual labels:  apple
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (-26.53%)
Mutual labels:  apple
Magnetic
SpriteKit Floating Bubble Picker (inspired by Apple Music) 🧲
Stars: ✭ 1,252 (+1177.55%)
Mutual labels:  apple
React Native Touch Id
React Native authentication with the native Touch ID popup.
Stars: ✭ 1,341 (+1268.37%)
Mutual labels:  apple
Emojiintelligence
Neural Network built in Apple Playground using Swift
Stars: ✭ 1,323 (+1250%)
Mutual labels:  apple
Jaromail
A commandline tool to easily and privately handle your e-mail
Stars: ✭ 86 (-12.24%)
Mutual labels:  apple

🌃 Insomnia

Insomnia Logo

Swift4.1 Coverage 100% Version License Platform Documentation

❤️ Please consider supporting my work, become my Sponsor! 🙏

Micro library to answer to questions like:

  • How to prevent screen lock on my application?
  • How can I prevent the display on an iOS device from dimming and turning off?
  • How do I prevent the iPhone screen from dimming or turning off while certain ViewController is presented?

Well... Sometimes you want your iPhone to stay active a little bit longer is it an import or just game interface.

This project aims to simplify the code and give you a well tested solution.

⚙ Modes:

  • .disabled - Nothing will change (disabled functionality).
  • .always - Your iOS device will never timeout and go to sleep.
  • .whenCharging - Device will stay active as long as it's connected to charger.

Important: If Insomnia instance is deallocated, it's functionality is automatically disabled and device will behave nominally (timeout, disable screen and lock).

👨‍💻 Usage:

1. Don't go to sleep, ever:

final class AppDelegate: UIApplicationDelegate {
	private let insomnia = Insomnia(mode: .always)
}

2. Same but only when charging:

final class AppDelegate: UIApplicationDelegate {
	private let insomnia = Insomnia(mode: .whenCharging)
}

3. Don't go to sleep if certain View Controller is alive:

final class SomeViewController: UIViewController {
	private let insomnia = Insomnia(mode: .always)
}

4. Change mode:

insomnia.mode = .always

🤔 Rationale:

The too simple answer is:

UIApplication.shared.isIdleTimerDisabled = true

The problem with this solution is that you have to remember to change this global variable to false when it's no longer needed. What if you want to activate it only when your device is on charger?

👏 Credits:

Logo design by Artur Martynowski - check his dribble profile, he's really great!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].