├── .gitignore ├── LICENCE ├── README.md ├── android ├── build.gradle ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── corbt │ └── keepawake │ ├── KCKeepAwake.java │ └── KCKeepAwakePackage.java ├── index.d.ts ├── index.js ├── ios ├── KCKeepAwake.h ├── KCKeepAwake.m └── KCKeepAwake.xcodeproj │ └── project.pbxproj ├── package.json └── react-native-keep-awake.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | .watchmanconfig 2 | 3 | # Android 4 | *.iml 5 | .gradle 6 | local.properties 7 | .idea/ 8 | gradle/ 9 | .DS_Store 10 | build/ 11 | captures/ 12 | 13 | # iOS 14 | xcuserdata/ 15 | *.xcworkspace/ 16 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Kyle Corbitt 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATION NOTICE 2 | 3 | This package has been deprecated. Please try either: 4 | * https://www.npmjs.com/package/expo-keep-awake This package matches functionality and is maintained by the excellent Expo team. 5 | * https://www.npmjs.com/package/@sayem314/react-native-keep-awake. This package is an up to date fork and does not require Expo. 6 | 7 | # END DEPRECATION NOTICE 8 | 9 | This React Native package allows you to prevent the screen from going to sleep while your app is active. It's useful for things like navigation or video playback, where the user expects the app to remain visible over long periods without touch interaction. 10 | 11 | ## Installation 12 | 13 | As the first step, install this module: 14 | 15 | ### React Native 0.57+ 16 | 17 | ``` 18 | npm install --save react-native-keep-awake 19 | ``` 20 | 21 | ### React Native 0.56 and below 22 | 23 | v4 of this module targets gradle 3 syntax, which is not available by default for React Native v0.56 and below. If you are targeting an older version of React Native, stick to v3 of this module: 24 | 25 | ``` 26 | npm install --save react-native-keep-awake@3 27 | ``` 28 | 29 | ### RNPM 30 | 31 | The plugin can be installed using [react-native link](https://facebook.github.io/react-native/docs/linking-libraries-ios.html) on both iOS and Android. Once installed with npm, just run: 32 | 33 | ``` 34 | react-native link react-native-keep-awake 35 | ``` 36 | 37 | ### Manual install 38 | 39 | #### iOS 40 | 41 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` 42 | 2. Go to `node_modules` ➜ `react-native-keep-awake` and add `KCKeepAwake.xcodeproj` 43 | 3. In XCode, in the project navigator, select your project. Add `libKCKeepAwake.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` 44 | 4. Click `KCKeepAwake.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). In the `Search Paths` section, look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../../react-native/React` and `$(SRCROOT)/../../../React` - mark both as `recursive`. 45 | 46 | 47 | #### Android 48 | 49 | 1. Open up `android/app/src/main/java/[...]/MainApplication.java (React Native 0.29+) 50 | - Add `import com.corbt.keepawake.KCKeepAwakePackage;` to the imports at the top of the file 51 | - Add `new KCKeepAwakePackage()` to the list returned by the `getPackages()` method 52 | 53 | 3. Append the following lines to `android/settings.gradle`: 54 | 55 | ```groovy 56 | include ':react-native-keep-awake' 57 | project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android') 58 | ``` 59 | 60 | 4. Insert the following lines inside the dependencies block in `android/app/build.gradle`: 61 | 62 | ```groovy 63 | compile project(':react-native-keep-awake') 64 | ``` 65 | 66 | ## Usage 67 | 68 | There are two ways to use this package: by rendering it as a component, or by explicitly calling 69 | the `KeepAwake.activate()` and `KeepAwake.deactivate()` static methods. Both are demonstrated below. 70 | 71 | ```jsx 72 | 73 | import React, { Component } from 'react'; 74 | import { View, Text } from 'react-native'; 75 | 76 | import KeepAwake from 'react-native-keep-awake'; 77 | 78 | // Method 1 79 | class MyComponent extends Component { 80 | render() { 81 | if (this.props.screenShouldBeAwake) { 82 | return ( 83 | 84 | Screen will be kept awake 85 | 86 | 87 | ) 88 | } else { 89 | return ( 90 | 91 | Screen can sleep 92 | 93 | ); 94 | } 95 | } 96 | } 97 | 98 | // Method 2 99 | function changeKeepAwake(shouldBeAwake) { 100 | if (shouldBeAwake) { 101 | KeepAwake.activate(); 102 | } else { 103 | KeepAwake.deactivate(); 104 | } 105 | } 106 | 107 | ``` 108 | 109 | In method 1, the screen will be locked awake when the `` component is mounted, and the lock will be disabled when the component is unmounted. Method 2 gives you more explicit control of when the lock is active or not. 110 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.1.4' 9 | } 10 | } 11 | 12 | apply plugin: 'com.android.library' 13 | 14 | def _ext = rootProject.ext 15 | 16 | def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+' 17 | def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 27 18 | def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3' 19 | def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16 20 | def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 27 21 | 22 | android { 23 | compileSdkVersion _compileSdkVersion 24 | buildToolsVersion _buildToolsVersion 25 | 26 | defaultConfig { 27 | minSdkVersion _minSdkVersion 28 | targetSdkVersion _targetSdkVersion 29 | versionCode 1 30 | versionName "1.0" 31 | } 32 | lintOptions { 33 | abortOnError false 34 | } 35 | } 36 | 37 | dependencies { 38 | //noinspection GradleDynamicVersion 39 | implementation "com.facebook.react:react-native:${_reactNativeVersion}" 40 | } 41 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/java/com/corbt/keepawake/KCKeepAwake.java: -------------------------------------------------------------------------------- 1 | // Adapted from 2 | // https://github.com/gijoehosaphat/react-native-keep-screen-on 3 | 4 | package com.corbt.keepawake; 5 | 6 | import android.app.Activity; 7 | import android.view.WindowManager; 8 | 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 11 | import com.facebook.react.bridge.ReactMethod; 12 | 13 | public class KCKeepAwake extends ReactContextBaseJavaModule { 14 | 15 | public KCKeepAwake(ReactApplicationContext reactContext) { 16 | super(reactContext); 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return "KCKeepAwake"; 22 | } 23 | 24 | @ReactMethod 25 | public void activate() { 26 | final Activity activity = getCurrentActivity(); 27 | 28 | if (activity != null) { 29 | activity.runOnUiThread(new Runnable() { 30 | @Override 31 | public void run() { 32 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | @ReactMethod 39 | public void deactivate() { 40 | final Activity activity = getCurrentActivity(); 41 | 42 | if (activity != null) { 43 | activity.runOnUiThread(new Runnable() { 44 | @Override 45 | public void run() { 46 | activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 47 | } 48 | }); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /android/src/main/java/com/corbt/keepawake/KCKeepAwakePackage.java: -------------------------------------------------------------------------------- 1 | // Adapted from 2 | // https://github.com/gijoehosaphat/react-native-keep-screen-on 3 | 4 | package com.corbt.keepawake; 5 | 6 | import com.facebook.react.ReactPackage; 7 | import com.facebook.react.bridge.JavaScriptModule; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | 12 | import java.util.*; 13 | 14 | public class KCKeepAwakePackage implements ReactPackage { 15 | 16 | @Override 17 | public List createNativeModules(ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | modules.add(new KCKeepAwake(reactContext)); 20 | return modules; 21 | } 22 | 23 | // Deprecated RN 0.47 24 | public List> createJSModules() { 25 | return Collections.emptyList(); 26 | } 27 | 28 | @Override 29 | public List createViewManagers(ReactApplicationContext reactContext) { 30 | return new ArrayList<>(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class KeepAwake extends React.Component { 4 | static activate(): void 5 | static deactivate(): void 6 | } 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React, { Component } from 'react'; 4 | import { NativeModules } from 'react-native'; 5 | 6 | let mounted = 0; 7 | 8 | export default class KeepAwake extends Component<{}> { 9 | static activate() { 10 | NativeModules.KCKeepAwake.activate(); 11 | } 12 | 13 | static deactivate() { 14 | NativeModules.KCKeepAwake.deactivate(); 15 | } 16 | 17 | componentDidMount() { 18 | mounted++; 19 | KeepAwake.activate(); 20 | } 21 | 22 | componentWillUnmount() { 23 | mounted--; 24 | if (!mounted) { 25 | KeepAwake.deactivate(); 26 | } 27 | } 28 | 29 | render() { 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/KCKeepAwake.h: -------------------------------------------------------------------------------- 1 | #if __has_include() 2 | #import 3 | #elif __has_include("RCTBridgeModule.h") 4 | #import "RCTBridgeModule.h" 5 | #else 6 | #import "React/RCTBridgeModule.h" 7 | #endif 8 | 9 | @interface KCKeepAwake : NSObject 10 | @end 11 | -------------------------------------------------------------------------------- /ios/KCKeepAwake.m: -------------------------------------------------------------------------------- 1 | #import "KCKeepAwake.h" 2 | #import "UIKit/UIKit.h" 3 | 4 | 5 | @implementation KCKeepAwake 6 | 7 | RCT_EXPORT_MODULE(); 8 | 9 | RCT_EXPORT_METHOD(activate) 10 | { 11 | dispatch_async(dispatch_get_main_queue(), ^{ 12 | [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; 13 | }); 14 | } 15 | 16 | RCT_EXPORT_METHOD(deactivate) 17 | { 18 | dispatch_async(dispatch_get_main_queue(), ^{ 19 | [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; 20 | }); 21 | } 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /ios/KCKeepAwake.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 13BE3DEE1AC21097009241FE /* KCKeepAwake.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* KCKeepAwake.m */; }; 11 | /* End PBXBuildFile section */ 12 | 13 | /* Begin PBXCopyFilesBuildPhase section */ 14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 15 | isa = PBXCopyFilesBuildPhase; 16 | buildActionMask = 2147483647; 17 | dstPath = "include/$(PRODUCT_NAME)"; 18 | dstSubfolderSpec = 16; 19 | files = ( 20 | ); 21 | runOnlyForDeploymentPostprocessing = 0; 22 | }; 23 | /* End PBXCopyFilesBuildPhase section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 134814201AA4EA6300B7C361 /* libKCKeepAwake.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKCKeepAwake.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 13BE3DEC1AC21097009241FE /* KCKeepAwake.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCKeepAwake.h; sourceTree = ""; }; 28 | 13BE3DED1AC21097009241FE /* KCKeepAwake.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCKeepAwake.m; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 134814211AA4EA7D00B7C361 /* Products */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 134814201AA4EA6300B7C361 /* libKCKeepAwake.a */, 46 | ); 47 | name = Products; 48 | sourceTree = ""; 49 | }; 50 | 58B511D21A9E6C8500147676 = { 51 | isa = PBXGroup; 52 | children = ( 53 | 13BE3DEC1AC21097009241FE /* KCKeepAwake.h */, 54 | 13BE3DED1AC21097009241FE /* KCKeepAwake.m */, 55 | 134814211AA4EA7D00B7C361 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | /* End PBXGroup section */ 60 | 61 | /* Begin PBXNativeTarget section */ 62 | 58B511DA1A9E6C8500147676 /* KCKeepAwake */ = { 63 | isa = PBXNativeTarget; 64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "KCKeepAwake" */; 65 | buildPhases = ( 66 | 58B511D71A9E6C8500147676 /* Sources */, 67 | 58B511D81A9E6C8500147676 /* Frameworks */, 68 | 58B511D91A9E6C8500147676 /* CopyFiles */, 69 | ); 70 | buildRules = ( 71 | ); 72 | dependencies = ( 73 | ); 74 | name = KCKeepAwake; 75 | productName = RCTDataManager; 76 | productReference = 134814201AA4EA6300B7C361 /* libKCKeepAwake.a */; 77 | productType = "com.apple.product-type.library.static"; 78 | }; 79 | /* End PBXNativeTarget section */ 80 | 81 | /* Begin PBXProject section */ 82 | 58B511D31A9E6C8500147676 /* Project object */ = { 83 | isa = PBXProject; 84 | attributes = { 85 | LastUpgradeCheck = 0610; 86 | ORGANIZATIONNAME = Facebook; 87 | TargetAttributes = { 88 | 58B511DA1A9E6C8500147676 = { 89 | CreatedOnToolsVersion = 6.1.1; 90 | }; 91 | }; 92 | }; 93 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "KCKeepAwake" */; 94 | compatibilityVersion = "Xcode 3.2"; 95 | developmentRegion = English; 96 | hasScannedForEncodings = 0; 97 | knownRegions = ( 98 | en, 99 | ); 100 | mainGroup = 58B511D21A9E6C8500147676; 101 | productRefGroup = 58B511D21A9E6C8500147676; 102 | projectDirPath = ""; 103 | projectRoot = ""; 104 | targets = ( 105 | 58B511DA1A9E6C8500147676 /* KCKeepAwake */, 106 | ); 107 | }; 108 | /* End PBXProject section */ 109 | 110 | /* Begin PBXSourcesBuildPhase section */ 111 | 58B511D71A9E6C8500147676 /* Sources */ = { 112 | isa = PBXSourcesBuildPhase; 113 | buildActionMask = 2147483647; 114 | files = ( 115 | 13BE3DEE1AC21097009241FE /* KCKeepAwake.m in Sources */, 116 | ); 117 | runOnlyForDeploymentPostprocessing = 0; 118 | }; 119 | /* End PBXSourcesBuildPhase section */ 120 | 121 | /* Begin XCBuildConfiguration section */ 122 | 58B511ED1A9E6C8500147676 /* Debug */ = { 123 | isa = XCBuildConfiguration; 124 | buildSettings = { 125 | ALWAYS_SEARCH_USER_PATHS = NO; 126 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 127 | CLANG_CXX_LIBRARY = "libc++"; 128 | CLANG_ENABLE_MODULES = YES; 129 | CLANG_ENABLE_OBJC_ARC = YES; 130 | CLANG_WARN_BOOL_CONVERSION = YES; 131 | CLANG_WARN_CONSTANT_CONVERSION = YES; 132 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 133 | CLANG_WARN_EMPTY_BODY = YES; 134 | CLANG_WARN_ENUM_CONVERSION = YES; 135 | CLANG_WARN_INT_CONVERSION = YES; 136 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 137 | CLANG_WARN_UNREACHABLE_CODE = YES; 138 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 139 | COPY_PHASE_STRIP = NO; 140 | ENABLE_STRICT_OBJC_MSGSEND = YES; 141 | GCC_C_LANGUAGE_STANDARD = gnu99; 142 | GCC_DYNAMIC_NO_PIC = NO; 143 | GCC_OPTIMIZATION_LEVEL = 0; 144 | GCC_PREPROCESSOR_DEFINITIONS = ( 145 | "DEBUG=1", 146 | "$(inherited)", 147 | ); 148 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 149 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 150 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 151 | GCC_WARN_UNDECLARED_SELECTOR = YES; 152 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 153 | GCC_WARN_UNUSED_FUNCTION = YES; 154 | GCC_WARN_UNUSED_VARIABLE = YES; 155 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 156 | MTL_ENABLE_DEBUG_INFO = YES; 157 | ONLY_ACTIVE_ARCH = YES; 158 | SDKROOT = iphoneos; 159 | }; 160 | name = Debug; 161 | }; 162 | 58B511EE1A9E6C8500147676 /* Release */ = { 163 | isa = XCBuildConfiguration; 164 | buildSettings = { 165 | ALWAYS_SEARCH_USER_PATHS = NO; 166 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 167 | CLANG_CXX_LIBRARY = "libc++"; 168 | CLANG_ENABLE_MODULES = YES; 169 | CLANG_ENABLE_OBJC_ARC = YES; 170 | CLANG_WARN_BOOL_CONVERSION = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 173 | CLANG_WARN_EMPTY_BODY = YES; 174 | CLANG_WARN_ENUM_CONVERSION = YES; 175 | CLANG_WARN_INT_CONVERSION = YES; 176 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 177 | CLANG_WARN_UNREACHABLE_CODE = YES; 178 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 179 | COPY_PHASE_STRIP = YES; 180 | ENABLE_NS_ASSERTIONS = NO; 181 | ENABLE_STRICT_OBJC_MSGSEND = YES; 182 | GCC_C_LANGUAGE_STANDARD = gnu99; 183 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 184 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 185 | GCC_WARN_UNDECLARED_SELECTOR = YES; 186 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 187 | GCC_WARN_UNUSED_FUNCTION = YES; 188 | GCC_WARN_UNUSED_VARIABLE = YES; 189 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 190 | MTL_ENABLE_DEBUG_INFO = NO; 191 | SDKROOT = iphoneos; 192 | VALIDATE_PRODUCT = YES; 193 | }; 194 | name = Release; 195 | }; 196 | 58B511F01A9E6C8500147676 /* Debug */ = { 197 | isa = XCBuildConfiguration; 198 | buildSettings = { 199 | HEADER_SEARCH_PATHS = ( 200 | "$(inherited)", 201 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 202 | "$(SRCROOT)/../../../React/**", 203 | "$(SRCROOT)/../../../node_modules/react-native/React/**", 204 | ); 205 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 206 | OTHER_LDFLAGS = "-ObjC"; 207 | PRODUCT_NAME = KCKeepAwake; 208 | SKIP_INSTALL = YES; 209 | }; 210 | name = Debug; 211 | }; 212 | 58B511F11A9E6C8500147676 /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | HEADER_SEARCH_PATHS = ( 216 | "$(inherited)", 217 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 218 | "$(SRCROOT)/../../../React/**", 219 | "$(SRCROOT)/../../../node_modules/react-native/React/**", 220 | ); 221 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 222 | OTHER_LDFLAGS = "-ObjC"; 223 | PRODUCT_NAME = KCKeepAwake; 224 | SKIP_INSTALL = YES; 225 | }; 226 | name = Release; 227 | }; 228 | /* End XCBuildConfiguration section */ 229 | 230 | /* Begin XCConfigurationList section */ 231 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "KCKeepAwake" */ = { 232 | isa = XCConfigurationList; 233 | buildConfigurations = ( 234 | 58B511ED1A9E6C8500147676 /* Debug */, 235 | 58B511EE1A9E6C8500147676 /* Release */, 236 | ); 237 | defaultConfigurationIsVisible = 0; 238 | defaultConfigurationName = Release; 239 | }; 240 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "KCKeepAwake" */ = { 241 | isa = XCConfigurationList; 242 | buildConfigurations = ( 243 | 58B511F01A9E6C8500147676 /* Debug */, 244 | 58B511F11A9E6C8500147676 /* Release */, 245 | ); 246 | defaultConfigurationIsVisible = 0; 247 | defaultConfigurationName = Release; 248 | }; 249 | /* End XCConfigurationList section */ 250 | }; 251 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 252 | } 253 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-keep-awake", 3 | "version": "4.0.0", 4 | "description": "Keep the screen from going to sleep. iOS and Android.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/corbt/react-native-keep-awake.git" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/corbt/react-native-keep-awake/issues" 12 | }, 13 | "homepage": "https://github.com/corbt/react-native-keep-awake#readme", 14 | "keywords": [ 15 | "react-native", 16 | "ios", 17 | "android", 18 | "awake", 19 | "screen", 20 | "lock", 21 | "sleep" 22 | ], 23 | "author": "Kyle Corbitt", 24 | "license": "MIT" 25 | } 26 | -------------------------------------------------------------------------------- /react-native-keep-awake.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = package['name'] 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.description = package['description'] 10 | s.license = package['license'] 11 | s.author = package['author'] 12 | s.homepage = package['homepage'] 13 | s.source = { :git => package['repository']['url'], :tag => s.version } 14 | 15 | s.requires_arc = true 16 | s.platform = :ios, '8.0' 17 | 18 | s.preserve_paths = 'README.md', 'package.json', 'index.js' 19 | s.source_files = 'ios/*.{h,m}' 20 | 21 | s.dependency 'React' 22 | end 23 | --------------------------------------------------------------------------------