├── .gitignore
├── .npmignore
├── README.md
├── android
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── gijoehosaphat
│ └── keepscreenon
│ ├── KeepScreenOnModule.java
│ └── KeepScreenOnPackage.java
├── index.js
├── ios
├── .gitignore
├── KeepScreenOn.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
└── KeepScreenOn
│ ├── KeepScreenOn.h
│ └── KeepScreenOn.m
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | android/build/*
2 | node_modules/
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 | npm-debug.log
29 |
30 | # OSX
31 | #
32 | .DS_Store
33 |
34 | # Xcode
35 | #
36 | build/
37 | *.pbxuser
38 | !default.pbxuser
39 | *.mode1v3
40 | !default.mode1v3
41 | *.mode2v3
42 | !default.mode2v3
43 | *.perspectivev3
44 | !default.perspectivev3
45 | xcuserdata
46 | *.xccheckout
47 | *.moved-aside
48 | DerivedData
49 | *.hmap
50 | *.ipa
51 | *.xcuserstate
52 | project.xcworkspace
53 |
54 | # Android/IJ
55 | #
56 | react-native-dialogs.iml
57 | .idea
58 | .gradle
59 | local.properties
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-keep-screen-on
2 | Allows for the selective toggling of the KEEP_SCREEN_ON flag (Android) and the setIdleTimerDisabled flag (iOS).
3 |
4 | ## Installation ##
5 | `npm install react-native-keep-screen-on --save`
6 |
7 | ## Configuration
8 | ### With [rnpm](https://github.com/rnpm/rnpm)
9 | Just run `rnpm link react-native-keep-screen-on`
10 |
11 | ### Manually
12 |
13 | #### In `settings.gradle` add the following lines:
14 |
15 | ```groovy
16 | include ':KeepScreenOn'
17 | project(':KeepScreenOn').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-screen-on/android')
18 | ```
19 |
20 | #### In `build.gradle` add the following line:
21 |
22 | ```groovy
23 | compile project(':KeepScreenOn')
24 | ```
25 |
26 | #### < [0.29] : In `MainActivity.java` add the following lines:
27 |
28 | ```java
29 | import com.gijoehosaphat.keepscreenon.KeepScreenOnPackage;
30 | ```
31 |
32 | ```java
33 | new KeepScreenOnPackage(this)
34 | ```
35 | #### >= [0.29] : In `MainApplication.java` add the following lines:
36 |
37 | ```java
38 | import com.gijoehosaphat.keepscreenon.KeepScreenOnPackage;
39 | ```
40 |
41 | ```java
42 | new KeepScreenOnPackage(this)
43 | ```
44 |
45 | ## Example usage:
46 |
47 | ```javascript
48 | import KeepScreenOn from 'react-native-keep-screen-on'
49 | ...
50 | //Keep screen on...
51 | KeepScreenOn.setKeepScreenOn(true)
52 |
53 | //Reset to default behavior...
54 | KeepScreenOn.setKeepScreenOn(false)
55 | ```
56 |
57 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | buildscript {
4 | repositories {
5 | mavenCentral()
6 | jcenter()
7 | maven {
8 | // All of React Native (JS, Android binaries) is installed from npm
9 | url "$rootDir/node_modules/react-native/android"
10 | }
11 | }
12 | }
13 |
14 | android {
15 | compileSdkVersion 23
16 | buildToolsVersion "23.0.1"
17 |
18 | defaultConfig {
19 | minSdkVersion 16
20 | targetSdkVersion 22
21 | versionCode 1
22 | versionName "1.0"
23 | ndk {
24 | abiFilters "armeabi-v7a", "x86"
25 | }
26 | }
27 | }
28 |
29 | dependencies {
30 | compile 'com.facebook.react:react-native:+'
31 | }
32 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/gijoehosaphat/keepscreenon/KeepScreenOnModule.java:
--------------------------------------------------------------------------------
1 | package com.gijoehosaphat.keepscreenon;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.view.WindowManager;
6 |
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
9 | import com.facebook.react.bridge.ReactMethod;
10 |
11 | public class KeepScreenOnModule extends ReactContextBaseJavaModule {
12 |
13 | private ReactApplicationContext mContext = null;
14 |
15 | public KeepScreenOnModule(ReactApplicationContext reactContext) {
16 | super(reactContext);
17 | this.mContext = reactContext;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "KeepScreenOn";
23 | }
24 |
25 | @ReactMethod
26 | public void setKeepScreenOn(Boolean bKeepScreenOn) {
27 | final Activity activity = getCurrentActivity();
28 | if (bKeepScreenOn == true) {
29 | if (activity != null) {
30 | activity.runOnUiThread(new Runnable() {
31 | @Override
32 | public void run() {
33 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
34 | }
35 | });
36 | }
37 | } else if (bKeepScreenOn == false) {
38 | if (activity != null) {
39 | activity.runOnUiThread(new Runnable() {
40 | @Override
41 | public void run() {
42 | activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
43 | }
44 | });
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/android/src/main/java/com/gijoehosaphat/keepscreenon/KeepScreenOnPackage.java:
--------------------------------------------------------------------------------
1 | package com.gijoehosaphat.keepscreenon;
2 |
3 | import android.app.Activity;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.uimanager.ViewManager;
10 |
11 | import java.util.*;
12 |
13 | public class KeepScreenOnPackage implements ReactPackage {
14 |
15 | public KeepScreenOnPackage() {
16 |
17 | }
18 |
19 | @Override
20 | public List createNativeModules(ReactApplicationContext reactContext) {
21 | List modules = new ArrayList<>();
22 | modules.add(new KeepScreenOnModule(reactContext));
23 | return modules;
24 | }
25 |
26 | @Override
27 | public List createViewManagers(ReactApplicationContext reactContext) {
28 | return Collections.emptyList();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var { NativeModules } = require('react-native')
4 |
5 | module.exports = NativeModules.KeepScreenOn
6 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | # CocoaPods
31 | #
32 | # We recommend against adding the Pods directory to your .gitignore. However
33 | # you should judge for yourself, the pros and cons are mentioned at:
34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
35 | #
36 | # Pods/
37 |
38 | # Carthage
39 | #
40 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
41 | # Carthage/Checkouts
42 |
43 | Carthage/Build
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51 |
52 | fastlane/report.xml
53 | fastlane/Preview.html
54 | fastlane/screenshots
55 | fastlane/test_output
56 |
57 | # Code Injection
58 | #
59 | # After new code Injection tools there's a generated folder /iOSInjectionProject
60 | # https://github.com/johnno1962/injectionforxcode
61 |
62 | iOSInjectionProject/
63 |
64 | .DS_Store
65 |
--------------------------------------------------------------------------------
/ios/KeepScreenOn.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 668B814B1DB666B90041B069 /* KeepScreenOn.m in Sources */ = {isa = PBXBuildFile; fileRef = 668B814A1DB666B90041B069 /* KeepScreenOn.m */; };
11 | 668B814C1DB666B90041B069 /* KeepScreenOn.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 668B81491DB666B90041B069 /* KeepScreenOn.h */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 668B81441DB666B90041B069 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = "include/$(PRODUCT_NAME)";
19 | dstSubfolderSpec = 16;
20 | files = (
21 | 668B814C1DB666B90041B069 /* KeepScreenOn.h in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 0;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 668B81461DB666B90041B069 /* libKeepScreenOn.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKeepScreenOn.a; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 668B81491DB666B90041B069 /* KeepScreenOn.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeepScreenOn.h; sourceTree = ""; };
30 | 668B814A1DB666B90041B069 /* KeepScreenOn.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KeepScreenOn.m; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 668B81431DB666B90041B069 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 668B813D1DB666B90041B069 = {
45 | isa = PBXGroup;
46 | children = (
47 | 668B81481DB666B90041B069 /* KeepScreenOn */,
48 | 668B81471DB666B90041B069 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 668B81471DB666B90041B069 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 668B81461DB666B90041B069 /* libKeepScreenOn.a */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 668B81481DB666B90041B069 /* KeepScreenOn */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 668B81491DB666B90041B069 /* KeepScreenOn.h */,
64 | 668B814A1DB666B90041B069 /* KeepScreenOn.m */,
65 | );
66 | path = KeepScreenOn;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 668B81451DB666B90041B069 /* KeepScreenOn */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 668B814F1DB666B90041B069 /* Build configuration list for PBXNativeTarget "KeepScreenOn" */;
75 | buildPhases = (
76 | 668B81421DB666B90041B069 /* Sources */,
77 | 668B81431DB666B90041B069 /* Frameworks */,
78 | 668B81441DB666B90041B069 /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = KeepScreenOn;
85 | productName = KeepScreenOn;
86 | productReference = 668B81461DB666B90041B069 /* libKeepScreenOn.a */;
87 | productType = "com.apple.product-type.library.static";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 668B813E1DB666B90041B069 /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0800;
96 | ORGANIZATIONNAME = "Mark Jamieson";
97 | TargetAttributes = {
98 | 668B81451DB666B90041B069 = {
99 | CreatedOnToolsVersion = 8.0;
100 | ProvisioningStyle = Automatic;
101 | };
102 | };
103 | };
104 | buildConfigurationList = 668B81411DB666B90041B069 /* Build configuration list for PBXProject "KeepScreenOn" */;
105 | compatibilityVersion = "Xcode 3.2";
106 | developmentRegion = English;
107 | hasScannedForEncodings = 0;
108 | knownRegions = (
109 | en,
110 | );
111 | mainGroup = 668B813D1DB666B90041B069;
112 | productRefGroup = 668B81471DB666B90041B069 /* Products */;
113 | projectDirPath = "";
114 | projectRoot = "";
115 | targets = (
116 | 668B81451DB666B90041B069 /* KeepScreenOn */,
117 | );
118 | };
119 | /* End PBXProject section */
120 |
121 | /* Begin PBXSourcesBuildPhase section */
122 | 668B81421DB666B90041B069 /* Sources */ = {
123 | isa = PBXSourcesBuildPhase;
124 | buildActionMask = 2147483647;
125 | files = (
126 | 668B814B1DB666B90041B069 /* KeepScreenOn.m in Sources */,
127 | );
128 | runOnlyForDeploymentPostprocessing = 0;
129 | };
130 | /* End PBXSourcesBuildPhase section */
131 |
132 | /* Begin XCBuildConfiguration section */
133 | 668B814D1DB666B90041B069 /* Debug */ = {
134 | isa = XCBuildConfiguration;
135 | buildSettings = {
136 | ALWAYS_SEARCH_USER_PATHS = NO;
137 | CLANG_ANALYZER_NONNULL = YES;
138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139 | CLANG_CXX_LIBRARY = "libc++";
140 | CLANG_ENABLE_MODULES = YES;
141 | CLANG_ENABLE_OBJC_ARC = YES;
142 | CLANG_WARN_BOOL_CONVERSION = YES;
143 | CLANG_WARN_CONSTANT_CONVERSION = YES;
144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
145 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
146 | CLANG_WARN_EMPTY_BODY = YES;
147 | CLANG_WARN_ENUM_CONVERSION = YES;
148 | CLANG_WARN_INFINITE_RECURSION = YES;
149 | CLANG_WARN_INT_CONVERSION = YES;
150 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
151 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
152 | CLANG_WARN_UNREACHABLE_CODE = YES;
153 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
154 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
155 | COPY_PHASE_STRIP = NO;
156 | DEBUG_INFORMATION_FORMAT = dwarf;
157 | ENABLE_STRICT_OBJC_MSGSEND = YES;
158 | ENABLE_TESTABILITY = YES;
159 | GCC_C_LANGUAGE_STANDARD = gnu99;
160 | GCC_DYNAMIC_NO_PIC = NO;
161 | GCC_NO_COMMON_BLOCKS = YES;
162 | GCC_OPTIMIZATION_LEVEL = 0;
163 | GCC_PREPROCESSOR_DEFINITIONS = (
164 | "DEBUG=1",
165 | "$(inherited)",
166 | );
167 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
168 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
169 | GCC_WARN_UNDECLARED_SELECTOR = YES;
170 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
171 | GCC_WARN_UNUSED_FUNCTION = YES;
172 | GCC_WARN_UNUSED_VARIABLE = YES;
173 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
174 | MTL_ENABLE_DEBUG_INFO = YES;
175 | ONLY_ACTIVE_ARCH = YES;
176 | SDKROOT = iphoneos;
177 | };
178 | name = Debug;
179 | };
180 | 668B814E1DB666B90041B069 /* Release */ = {
181 | isa = XCBuildConfiguration;
182 | buildSettings = {
183 | ALWAYS_SEARCH_USER_PATHS = NO;
184 | CLANG_ANALYZER_NONNULL = YES;
185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
186 | CLANG_CXX_LIBRARY = "libc++";
187 | CLANG_ENABLE_MODULES = YES;
188 | CLANG_ENABLE_OBJC_ARC = YES;
189 | CLANG_WARN_BOOL_CONVERSION = YES;
190 | CLANG_WARN_CONSTANT_CONVERSION = YES;
191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
192 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
193 | CLANG_WARN_EMPTY_BODY = YES;
194 | CLANG_WARN_ENUM_CONVERSION = YES;
195 | CLANG_WARN_INFINITE_RECURSION = YES;
196 | CLANG_WARN_INT_CONVERSION = YES;
197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
198 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
199 | CLANG_WARN_UNREACHABLE_CODE = YES;
200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
202 | COPY_PHASE_STRIP = NO;
203 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
204 | ENABLE_NS_ASSERTIONS = NO;
205 | ENABLE_STRICT_OBJC_MSGSEND = YES;
206 | GCC_C_LANGUAGE_STANDARD = gnu99;
207 | GCC_NO_COMMON_BLOCKS = YES;
208 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
209 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
210 | GCC_WARN_UNDECLARED_SELECTOR = YES;
211 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
212 | GCC_WARN_UNUSED_FUNCTION = YES;
213 | GCC_WARN_UNUSED_VARIABLE = YES;
214 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
215 | MTL_ENABLE_DEBUG_INFO = NO;
216 | SDKROOT = iphoneos;
217 | VALIDATE_PRODUCT = YES;
218 | };
219 | name = Release;
220 | };
221 | 668B81501DB666B90041B069 /* Debug */ = {
222 | isa = XCBuildConfiguration;
223 | buildSettings = {
224 | OTHER_LDFLAGS = "-ObjC";
225 | PRODUCT_NAME = "$(TARGET_NAME)";
226 | SKIP_INSTALL = YES;
227 | };
228 | name = Debug;
229 | };
230 | 668B81511DB666B90041B069 /* Release */ = {
231 | isa = XCBuildConfiguration;
232 | buildSettings = {
233 | OTHER_LDFLAGS = "-ObjC";
234 | PRODUCT_NAME = "$(TARGET_NAME)";
235 | SKIP_INSTALL = YES;
236 | };
237 | name = Release;
238 | };
239 | /* End XCBuildConfiguration section */
240 |
241 | /* Begin XCConfigurationList section */
242 | 668B81411DB666B90041B069 /* Build configuration list for PBXProject "KeepScreenOn" */ = {
243 | isa = XCConfigurationList;
244 | buildConfigurations = (
245 | 668B814D1DB666B90041B069 /* Debug */,
246 | 668B814E1DB666B90041B069 /* Release */,
247 | );
248 | defaultConfigurationIsVisible = 0;
249 | defaultConfigurationName = Release;
250 | };
251 | 668B814F1DB666B90041B069 /* Build configuration list for PBXNativeTarget "KeepScreenOn" */ = {
252 | isa = XCConfigurationList;
253 | buildConfigurations = (
254 | 668B81501DB666B90041B069 /* Debug */,
255 | 668B81511DB666B90041B069 /* Release */,
256 | );
257 | defaultConfigurationIsVisible = 0;
258 | defaultConfigurationName = Release;
259 | };
260 | /* End XCConfigurationList section */
261 | };
262 | rootObject = 668B813E1DB666B90041B069 /* Project object */;
263 | }
264 |
--------------------------------------------------------------------------------
/ios/KeepScreenOn.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/KeepScreenOn/KeepScreenOn.h:
--------------------------------------------------------------------------------
1 | //
2 | // KeepScreenOn.h
3 | // KeepScreenOn
4 | //
5 | // Created by Mark Jamieson on 2016-10-18.
6 | // Copyright © 2016 Mark Jamieson. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @interface KeepScreenOn : NSObject
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/KeepScreenOn/KeepScreenOn.m:
--------------------------------------------------------------------------------
1 | //
2 | // KeepScreenOn.m
3 | // KeepScreenOn
4 | //
5 | // Created by Mark Jamieson on 2016-10-18.
6 | // Copyright © 2016 Mark Jamieson. All rights reserved.
7 | //
8 |
9 | #import "KeepScreenOn.h"
10 |
11 | @implementation KeepScreenOn
12 |
13 | RCT_EXPORT_MODULE();
14 |
15 | RCT_EXPORT_METHOD(setKeepScreenOn:(BOOL)screenShouldBeKeptOn)
16 | {
17 | dispatch_async(dispatch_get_main_queue(), ^{
18 | [[UIApplication sharedApplication] setIdleTimerDisabled:screenShouldBeKeptOn];
19 | });
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": {
3 | "email": "joeleonard@gmail.com",
4 | "name": "Joe Leonard"
5 | },
6 | "bugs": {
7 | "url": "https://github.com/gijoehosaphat/react-native-keep-screen-on/issues"
8 | },
9 | "dependencies": {},
10 | "description": "React Native module to selective toggle KEEP_SCREEN_ON flag.",
11 | "devDependencies": {},
12 | "homepage": "https://github.com/gijoehosaphat/react-native-keep-screen-on#readme",
13 | "license": "MIT",
14 | "main": "index.js",
15 | "maintainers": [
16 | {
17 | "name": "gijoehosaphat",
18 | "email": "joeleonard@gmail.com"
19 | }
20 | ],
21 | "name": "react-native-keep-screen-on",
22 | "optionalDependencies": {},
23 | "repository": {
24 | "type": "git",
25 | "url": "git+ssh://git@github.com/gijoehosaphat/react-native-keep-screen-on.git"
26 | },
27 | "version": "1.2.0",
28 | "keywords": [
29 | "react-component",
30 | "react-native",
31 | "android"
32 | ],
33 | "peerDependencies": {
34 | "react-native": "*"
35 | },
36 | "rnpm": {
37 | "android": {
38 | "packageInstance": "new KeepScreenOnPackage(this)"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------