├── android
├── gradle.properties
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── sayem
│ │ │ └── keepawake
│ │ │ ├── KCKeepAwakeImpl.java
│ │ │ └── KCKeepAwakePackage.java
│ ├── newarch
│ │ └── com
│ │ │ └── sayem
│ │ │ └── keepawake
│ │ │ └── KCKeepAwake.java
│ └── oldarch
│ │ └── com
│ │ └── sayem
│ │ └── keepawake
│ │ └── KCKeepAwake.java
├── build.gradle
├── gradlew.bat
└── gradlew
├── .gitignore
├── index.js
├── NativeKCKeepAwake.ts
├── Class.js
├── ios
├── ReactNativeKCKeepAwake.h
├── ReactNativeKCKeepAwake.mm
└── ReactNativeKCKeepAwake.xcodeproj
│ └── project.pbxproj
├── index.d.ts
├── index.native.js
├── package.json
├── LICENCE
├── react-native-keep-awake.podspec
└── README.md
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | android.enableJetifier=true
2 | android.useAndroidX=true
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export function useKeepAwake() {}
4 |
5 | export function activateKeepAwake() {}
6 |
7 | export function deactivateKeepAwake() {}
8 |
9 | export default function KeepAwake() {
10 | return null;
11 | }
12 |
--------------------------------------------------------------------------------
/NativeKCKeepAwake.ts:
--------------------------------------------------------------------------------
1 | import type { TurboModule } from 'react-native';
2 | import { TurboModuleRegistry } from 'react-native';
3 |
4 | export interface Spec extends TurboModule {
5 | activate: () => void;
6 | deactivate: () => void;
7 | }
8 |
9 | export default TurboModuleRegistry.getEnforcing('ReactNativeKCKeepAwake');
--------------------------------------------------------------------------------
/Class.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { NativeModules } from "react-native";
3 |
4 | export default class KeepAwake extends React.Component {
5 | static activate() {
6 | NativeModules.KCKeepAwake.activate();
7 | }
8 |
9 | static deactivate() {
10 | NativeModules.KCKeepAwake.deactivate();
11 | }
12 |
13 | componentDidMount() {
14 | KeepAwake.activate();
15 | }
16 |
17 | componentWillUnmount() {
18 | KeepAwake.deactivate();
19 | }
20 |
21 | render() {
22 | return null;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ios/ReactNativeKCKeepAwake.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 | #if RCT_NEW_ARCH_ENABLED
10 | #import "ReactNativeKCKeepAwakeSpec.h"
11 | #endif
12 |
13 | @interface ReactNativeKCKeepAwake : NSObject
14 | @end
15 |
16 | #if RCT_NEW_ARCH_ENABLED
17 | @interface ReactNativeKCKeepAwake ()
18 | @end
19 | #endif
20 |
--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | import {FunctionComponent} from 'react';
2 |
3 | /**
4 | * Prevent the screen from sleeping.
5 | */
6 | export function activateKeepAwake(): void;
7 |
8 | /**
9 | * Releases screen-sleep prevention.
10 | */
11 | export function deactivateKeepAwake(): void;
12 |
13 | /**
14 | * React hook to keep the screen awake for as long as the owner component
15 | * is mounted.
16 | */
17 | export function useKeepAwake(): void;
18 |
19 | /**
20 | * React component to keep the screen awake while this component is rendered.
21 | */
22 | declare const KeepAwake: FunctionComponent;
23 | export default KeepAwake;
24 |
--------------------------------------------------------------------------------
/index.native.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 |
3 | import ReactNativeKCKeepAwake from "./NativeKCKeepAwake";
4 |
5 | export const activateKeepAwake = () => {
6 | ReactNativeKCKeepAwake.activate();
7 | };
8 |
9 | export const deactivateKeepAwake = () => {
10 | ReactNativeKCKeepAwake.deactivate();
11 | };
12 |
13 | export const useKeepAwake = () => {
14 | useEffect(() => {
15 | activateKeepAwake();
16 | return deactivateKeepAwake;
17 | }, []);
18 | };
19 |
20 | export default () => {
21 | useEffect(() => {
22 | activateKeepAwake();
23 | return deactivateKeepAwake;
24 | }, []);
25 |
26 | return null;
27 | };
28 |
--------------------------------------------------------------------------------
/android/src/newarch/com/sayem/keepawake/KCKeepAwake.java:
--------------------------------------------------------------------------------
1 | package com.sayem.keepawake;
2 |
3 | import android.os.Build;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 |
9 | import com.sayem.keepawake.NativeKCKeepAwakeSpec;
10 |
11 | import android.util.Log;
12 |
13 | public class KCKeepAwake extends NativeKCKeepAwakeSpec {
14 |
15 | private final KCKeepAwakeImpl delegate;
16 |
17 | public KCKeepAwake(ReactApplicationContext reactContext) {
18 | super(reactContext);
19 | delegate = new KCKeepAwakeImpl(reactContext);
20 | }
21 |
22 | @NonNull
23 | @Override
24 | public String getName() {
25 | return KCKeepAwakeImpl.NAME;
26 | }
27 |
28 | @Override
29 | public void activate() {
30 | delegate.activate();
31 | }
32 |
33 | @Override
34 | public void deactivate() {
35 | delegate.deactivate();
36 | }
37 | }
--------------------------------------------------------------------------------
/ios/ReactNativeKCKeepAwake.mm:
--------------------------------------------------------------------------------
1 | #import "ReactNativeKCKeepAwake.h"
2 | #import "UIKit/UIKit.h"
3 |
4 |
5 | #if RCT_NEW_ARCH_ENABLED
6 | #import "ReactNativeKCKeepAwakeSpec.h"
7 | #endif
8 |
9 |
10 | @implementation ReactNativeKCKeepAwake
11 |
12 | RCT_EXPORT_MODULE();
13 |
14 | RCT_EXPORT_METHOD(activate)
15 | {
16 | dispatch_async(dispatch_get_main_queue(), ^{
17 | [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
18 | });
19 | }
20 |
21 | RCT_EXPORT_METHOD(deactivate)
22 | {
23 | dispatch_async(dispatch_get_main_queue(), ^{
24 | [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
25 | });
26 | }
27 |
28 | # pragma mark - New Architecture
29 | #if RCT_NEW_ARCH_ENABLED
30 | - (std::shared_ptr)getTurboModule:
31 | (const facebook::react::ObjCTurboModule::InitParams &)params
32 | {
33 | return std::make_shared(params);
34 | }
35 | #endif
36 |
37 | @end
38 |
39 |
--------------------------------------------------------------------------------
/android/src/oldarch/com/sayem/keepawake/KCKeepAwake.java:
--------------------------------------------------------------------------------
1 | // Adapted from
2 | // https://github.com/gijoehosaphat/react-native-keep-screen-on
3 |
4 | package com.sayem.keepawake;
5 |
6 | import android.app.Activity;
7 |
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
10 | import com.facebook.react.bridge.ReactMethod;
11 |
12 | public class KCKeepAwake extends ReactContextBaseJavaModule {
13 |
14 | private final KCKeepAwakeImpl delegate;
15 |
16 | public KCKeepAwake(ReactApplicationContext reactContext) {
17 | super(reactContext);
18 | delegate = new KCKeepAwakeImpl(reactContext);
19 | }
20 |
21 | @Override
22 | public String getName() {
23 | return KCKeepAwakeImpl.NAME;
24 | }
25 |
26 | @ReactMethod
27 | public void activate() {
28 | delegate.activate();
29 | }
30 |
31 | @ReactMethod
32 | public void deactivate() {
33 | delegate.deactivate();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@sayem314/react-native-keep-awake",
3 | "version": "1.4.0",
4 | "description": "Keep the screen from going to sleep. iOS, Android and Web.",
5 | "main": "index",
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/sayem314/react-native-keep-awake.git"
9 | },
10 | "funding": {
11 | "type": "individual",
12 | "url": "https://github.com/sponsors/sayem314"
13 | },
14 | "bugs": {
15 | "url": "https://github.com/sayem314/react-native-keep-awake/issues"
16 | },
17 | "homepage": "https://github.com/sayem314/react-native-keep-awake",
18 | "keywords": [
19 | "react-native",
20 | "ios",
21 | "android",
22 | "awake",
23 | "screen",
24 | "lock",
25 | "sleep"
26 | ],
27 | "author": "Sayem Chowdhury",
28 | "license": "MIT",
29 | "codegenConfig": {
30 | "name": "ReactNativeKCKeepAwakeSpec",
31 | "type": "modules",
32 | "jsSrcsDir": ".",
33 | "android": {
34 | "javaPackageName": "com.sayem.keepawake"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Kyle Corbitt
4 | Copyright (c) 2020 Sayem Chowdhury
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/android/src/main/java/com/sayem/keepawake/KCKeepAwakeImpl.java:
--------------------------------------------------------------------------------
1 | package com.sayem.keepawake;
2 |
3 | import android.app.Activity;
4 | import android.view.WindowManager;
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 |
7 | class KCKeepAwakeImpl {
8 |
9 | public static final String NAME = "ReactNativeKCKeepAwake";
10 |
11 | static ReactApplicationContext RCTContext;
12 |
13 | public KCKeepAwakeImpl(ReactApplicationContext reactContext) {
14 | RCTContext = reactContext;
15 | }
16 |
17 | public void activate() {
18 | final Activity activity = RCTContext.getCurrentActivity();
19 |
20 | if (activity != null) {
21 | activity.runOnUiThread(new Runnable() {
22 | @Override
23 | public void run() {
24 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
25 | }
26 | });
27 | }
28 | }
29 |
30 | public void deactivate() {
31 | final Activity activity = RCTContext.getCurrentActivity();
32 |
33 | if (activity != null) {
34 | activity.runOnUiThread(new Runnable() {
35 | @Override
36 | public void run() {
37 | activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
38 | }
39 | });
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/react-native-keep-awake.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6 |
7 | Pod::Spec.new do |s|
8 | s.name = 'react-native-keep-awake'
9 | s.version = package['version']
10 | s.summary = package['description']
11 | s.description = package['description']
12 | s.license = package['license']
13 | s.author = package['author']
14 | s.homepage = package['homepage']
15 | s.source = { :git => package['repository']['url'], :tag => s.version }
16 |
17 | s.requires_arc = true
18 | s.platform = :ios, '8.0'
19 |
20 | s.preserve_paths = 'README.md', 'package.json', 'index.js'
21 | s.source_files = 'ios/*.{h,m,mm}'
22 |
23 | s.dependency 'React-Core'
24 |
25 | if ENV["RCT_NEW_ARCH_ENABLED"] == "1"
26 | s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
27 | s.pod_target_xcconfig = {
28 | "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
29 | "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
30 | "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
31 | }
32 |
33 | s.dependency "React-Codegen"
34 | s.dependency "React-RCTFabric"
35 | s.dependency "RCTRequired"
36 | s.dependency "RCTTypeSafety"
37 | s.dependency "ReactCommon/turbomodule/core"
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/android/src/main/java/com/sayem/keepawake/KCKeepAwakePackage.java:
--------------------------------------------------------------------------------
1 | package com.sayem.keepawake;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.facebook.react.TurboReactPackage;
6 | import com.facebook.react.bridge.NativeModule;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.module.model.ReactModuleInfo;
9 | import com.facebook.react.module.model.ReactModuleInfoProvider;
10 |
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | public class KCKeepAwakePackage extends TurboReactPackage {
15 |
16 | @Nullable
17 | @Override
18 | public NativeModule getModule(String name, ReactApplicationContext reactContext) {
19 | if (name.equals(KCKeepAwakeImpl.NAME)) {
20 | return new KCKeepAwake(reactContext);
21 | } else {
22 | return null;
23 | }
24 | }
25 |
26 | @Override
27 | public ReactModuleInfoProvider getReactModuleInfoProvider() {
28 | return () -> {
29 | final Map moduleInfos = new HashMap<>();
30 | boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
31 | moduleInfos.put(
32 | KCKeepAwakeImpl.NAME,
33 | new ReactModuleInfo(
34 | KCKeepAwakeImpl.NAME,
35 | KCKeepAwakeImpl.NAME,
36 | false, // canOverrideExistingModule
37 | false, // needsEagerInit
38 | false, // hasConstants
39 | false, // isCxxModule
40 | isTurboModule // isTurboModule
41 | ));
42 | return moduleInfos;
43 | };
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.safeExtGet = {prop, fallback ->
3 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
4 | }
5 | repositories {
6 | google()
7 | gradlePluginPortal()
8 | }
9 | dependencies {
10 | classpath("com.android.tools.build:gradle:7.3.1")
11 | }
12 | }
13 |
14 | def isNewArchitectureEnabled() {
15 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
16 | }
17 |
18 | apply plugin: 'com.android.library'
19 | if (isNewArchitectureEnabled()) {
20 | apply plugin: 'com.facebook.react'
21 | }
22 |
23 | android {
24 | def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
25 | if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
26 | namespace "com.sayem.keepawake"
27 | }
28 |
29 | compileSdkVersion safeExtGet('compileSdkVersion', 31)
30 |
31 | defaultConfig {
32 | minSdkVersion safeExtGet('minSdkVersion', 21)
33 | targetSdkVersion safeExtGet('targetSdkVersion', 31)
34 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
35 | }
36 |
37 | sourceSets {
38 | main {
39 | if (isNewArchitectureEnabled()) {
40 | java.srcDirs += ['src/newarch']
41 | } else {
42 | java.srcDirs += ['src/oldarch']
43 | }
44 | }
45 | }
46 | }
47 |
48 | repositories {
49 | maven {
50 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
51 | url "$projectDir/../node_modules/react-native/android"
52 | }
53 | mavenCentral()
54 | google()
55 | }
56 |
57 | dependencies {
58 | implementation 'com.facebook.react:react-native:+'
59 | }
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 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.
2 |
3 | ## Installation
4 |
5 | As the first step, install this module:
6 |
7 | #### React Native 0.60+
8 |
9 | `yarn add @sayem314/react-native-keep-awake`
10 |
11 | #### React Native new architecture
12 |
13 | You must use `react-native-keep-awake@1.2.0` or newer if you want to use the [RN new architecture](https://reactnative.dev/docs/the-new-architecture/landing-page).
14 |
15 | ## Usage
16 |
17 | #### example: hooks
18 |
19 | ```js
20 | import { useKeepAwake } from '@sayem314/react-native-keep-awake';
21 | import React from 'react';
22 | import { Text, View } from 'react-native';
23 |
24 | export default function KeepAwakeExample {
25 | useKeepAwake();
26 |
27 | return (
28 |
29 | This screen will never sleep!
30 |
31 | );
32 | }
33 | ```
34 |
35 | #### example: components
36 |
37 | ```js
38 | import KeepAwake from '@sayem314/react-native-keep-awake';
39 | import React from 'react';
40 | import { Text, View } from 'react-native';
41 |
42 | export default function KeepAwakeExample {
43 | return (
44 |
45 |
46 | This screen will never sleep!
47 |
48 | );
49 | }
50 | ```
51 |
52 | #### example: functions
53 |
54 | ```js
55 | import { activateKeepAwake, deactivateKeepAwake} from "@sayem314/react-native-keep-awake";
56 | import React from "react";
57 | import { Button, View } from "react-native";
58 |
59 | export default class KeepAwakeExample extends React.Component {
60 | render() {
61 | return (
62 |
63 |
64 |
65 |
66 | );
67 | }
68 |
69 | _activate = () => {
70 | activateKeepAwake();
71 | };
72 |
73 | _deactivate = () => {
74 | deactivateKeepAwake();
75 | };
76 | }
77 | ```
78 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/ios/ReactNativeKCKeepAwake.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 13BE3DEE1AC21097009241FE /* ReactNativeKCKeepAwake.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* ReactNativeKCKeepAwake.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 /* libReactNativeKCKeepAwake.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNativeKCKeepAwake.a; sourceTree = BUILT_PRODUCTS_DIR; };
27 | 13BE3DEC1AC21097009241FE /* ReactNativeKCKeepAwake.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReactNativeKCKeepAwake.h; sourceTree = ""; };
28 | 13BE3DED1AC21097009241FE /* ReactNativeKCKeepAwake.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNativeKCKeepAwake.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 /* libReactNativeKCKeepAwake.a */,
46 | );
47 | name = Products;
48 | sourceTree = "";
49 | };
50 | 58B511D21A9E6C8500147676 = {
51 | isa = PBXGroup;
52 | children = (
53 | 13BE3DEC1AC21097009241FE /* ReactNativeKCKeepAwake.h */,
54 | 13BE3DED1AC21097009241FE /* ReactNativeKCKeepAwake.m */,
55 | 134814211AA4EA7D00B7C361 /* Products */,
56 | );
57 | sourceTree = "";
58 | };
59 | /* End PBXGroup section */
60 |
61 | /* Begin PBXNativeTarget section */
62 | 58B511DA1A9E6C8500147676 /* ReactNativeKCKeepAwake */ = {
63 | isa = PBXNativeTarget;
64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "ReactNativeKCKeepAwake" */;
65 | buildPhases = (
66 | 58B511D71A9E6C8500147676 /* Sources */,
67 | 58B511D81A9E6C8500147676 /* Frameworks */,
68 | 58B511D91A9E6C8500147676 /* CopyFiles */,
69 | );
70 | buildRules = (
71 | );
72 | dependencies = (
73 | );
74 | name = ReactNativeKCKeepAwake;
75 | productName = RCTDataManager;
76 | productReference = 134814201AA4EA6300B7C361 /* libReactNativeKCKeepAwake.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 "ReactNativeKCKeepAwake" */;
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 /* ReactNativeKCKeepAwake */,
106 | );
107 | };
108 | /* End PBXProject section */
109 |
110 | /* Begin PBXSourcesBuildPhase section */
111 | 58B511D71A9E6C8500147676 /* Sources */ = {
112 | isa = PBXSourcesBuildPhase;
113 | buildActionMask = 2147483647;
114 | files = (
115 | 13BE3DEE1AC21097009241FE /* ReactNativeKCKeepAwake.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 = ReactNativeKCKeepAwake;
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 = ReactNativeKCKeepAwake;
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 "ReactNativeKCKeepAwake" */ = {
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 "ReactNativeKCKeepAwake" */ = {
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 |
--------------------------------------------------------------------------------