Git Product home page Git Product logo

react-native-keep-awake's Introduction

DEPRECATION NOTICE

This package has been deprecated. Please try either:

END DEPRECATION NOTICE

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.

Installation

As the first step, install this module:

React Native 0.57+

npm install --save react-native-keep-awake

React Native 0.56 and below

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:

npm install --save react-native-keep-awake@3

RNPM

The plugin can be installed using react-native link on both iOS and Android. Once installed with npm, just run:

react-native link react-native-keep-awake

Manual install

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-keep-awake and add KCKeepAwake.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libKCKeepAwake.a to your project's Build PhasesLink Binary With Libraries
  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.

Android

  1. Open up `android/app/src/main/java/[...]/MainApplication.java (React Native 0.29+)
  • Add import com.corbt.keepawake.KCKeepAwakePackage; to the imports at the top of the file
  • Add new KCKeepAwakePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
include ':react-native-keep-awake'
	project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-keep-awake/android')
  1. Insert the following lines inside the dependencies block in android/app/build.gradle:
compile project(':react-native-keep-awake')

Usage

There are two ways to use this package: by rendering it as a component, or by explicitly calling the KeepAwake.activate() and KeepAwake.deactivate() static methods. Both are demonstrated below.

import React, { Component } from 'react';
import { View, Text } from 'react-native';

import KeepAwake from 'react-native-keep-awake';

// Method 1
class MyComponent extends Component {
  render() {
    if (this.props.screenShouldBeAwake) {
      return (
        <View>
          <Text>Screen will be kept awake</Text>
          <KeepAwake />
        </View>
      )
    } else {
      return (
        <View>
          <Text>Screen can sleep</Text>
        </View>
      );
    }
  }
}

// Method 2
function changeKeepAwake(shouldBeAwake) {
  if (shouldBeAwake) {
    KeepAwake.activate();
  } else {
    KeepAwake.deactivate();
  }
}

In method 1, the screen will be locked awake when the <KeepAwake /> 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.

react-native-keep-awake's People

Contributors

asaenvoy avatar atticoos avatar avishayil avatar barbiero avatar bitcrumb avatar brad-sf avatar chentsulin avatar chiraggshah avatar corbt avatar cptfabulouso avatar dodie avatar fiznool avatar goldylucks avatar jerolimov avatar jpgarcia avatar manask88 avatar nambrot avatar pdsouza avatar radko93 avatar rakannimer avatar sriraman avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-keep-awake's Issues

Jest mock support

In case you need to mock this native module out for testing:

const keepAwake = require('react-native-keep-awake')
keepAwake.activate = () => console.log('stay awake!')
keepAwake.deactivate = () => console.log('go to sleep!')

RN Keep Awake is not compatible with React Native 0.56 (Android)

This package will not compile with React Native 0.56. Due to Google's mandate to target SDK 26 by 1 August 2018, React Native upgraded their target SDK. This is change in not compatible with react-native-keep-awake.

New apps will not be able to submit to the Google Play store as of 1 August 2018 unless they use React Natvie 0.56, so a fix to this issue is time sensitive.

Replication:

  1. Create a new react native app using react-native init
  2. Install react-native-keep-awake by following the instructions in this repo.
  3. Run the app on an android device by executing react-native run-android.
  4. This is the error message:
A problem occurred configuring project ':react-native-keep-awake'.
      > The SDK Build Tools revision (23.0.1) is too low for project ':react-native-keep-awake'. Minimum required is 25.0.0

package.json:

"dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-keep-awake": "^3.0.1"
  },

Trouble with RN 0.43.1

glass

I already removed node_modules and reinstalled. Still same issue when calling KeepAwake.activate()

Any ideas?

[Android] Screen does not stay on after activity is destroyed

This is very serious bug since it totally breaks this functionality on Android :/ The problem comes when operating system kills the activity. This happens for example when you put app to background and start using some other app which requires lot of memory. In this case operating system destroys activities which are not present at the moment.

How to reproduce:

  1. Make new project with react-native init testKeepAwakeBug
  2. Install this library according to instructions https://github.com/corbt/react-native-keep-awake#installation
  3. Add call to KeepAwake in root component:
componentDidMount() {
  KeepAwake.activate();
}
  1. This is most important part since this helps debugging. Set "Don't keep activities" to ON from Android settings. (Settings -> Developer options -> Don't keep actitivies)
  2. Open app in real phone and put screen sleep time to minimum (for example 15 seconds) so you don't have to wait that long
  3. Observe that screen does not go to sleep because KeepAwake.activate(); is called
  4. Put app to background (at this point activity is killed right away because of step 4)
  5. Go back to app and observe that the screen GOES to sleep after 15 seconds

Please tell me if you need more info! :)

It does not work in my project

Hello. Thank you for you work. But this package works fine in a new empty project, created a moment ago, but does not work in my real project. React-native version is 0.52.2 in both projects. Maybe you know what could be the causes of incorrect work?

Works fine

{
  "name": "rnKeepAwakeTest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.2",
    "react-native-keep-awake": "^2.0.6",
  },
  "devDependencies": {
    "babel-jest": "22.1.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.1.4",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Does not work

{
  "name": "yufuphone",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "camelcase-keys": "^4.1.0",
    "color": "^3.0.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "native-base": "^2.3.7",
    "prop-types": "^15.5.10",
    "react": "16.2.0",
    "react-native": "0.52.2",
    "react-native-action-button": "^2.8.4",
    "react-native-actioncable": "^0.0.3",
    "react-native-android-permissions": "^1.0.0",
    "react-native-animatable": "^1.2.4",
    "react-native-callkit": "^1.3.1",
    "react-native-code-push": "^5.2.1",
    "react-native-communications": "^2.2.1",
    "react-native-config": "^0.11.5",
    "react-native-contacts": "^2.1.1",
    "react-native-device-info": "^0.14.0",
    "react-native-exception-handler": "^2.7.1",
    "react-native-flags": "^1.0.0",
    "react-native-geocoder": "^0.5.0",
    "react-native-i18n": "^2.0.11",
    "react-native-image-crop-picker": "^0.19.1",
    "react-native-image-picker": "^0.26.7",
    "react-native-image-progress": "^1.0.1",
    "react-native-in-app-notification": "^2.2.0",
    "react-native-infinite-scroll-view": "^0.4.3",
    "react-native-keep-awake": "^2.0.6",
    "react-native-keyboard-aware-scroll-view": "^0.4.3",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-material-tabs": "https://github.com/pohodnya/react-native-material-tabs",
    "react-native-navigation-redux-helpers": "^0.5.0",
    "react-native-newrelic": "^1.1.1",
    "react-native-onesignal": "^3.0.9",
    "react-native-pjsip": "^2.7.1",
    "react-native-progress": "^3.4.0",
    "react-native-prompt": "https://github.com/pohodnya/react-native-prompt",
    "react-native-qrcode-svg": "^5.0.6",
    "react-native-restart": "^0.0.6",
    "react-native-round-flags": "^1.0.4",
    "react-native-sglistview": "^0.4.5",
    "react-native-share": "^1.0.24",
    "react-native-slider": "^0.11.0",
    "react-native-statusbar-alert": "^0.4.0",
    "react-native-svg": "6.0.0",
    "react-native-swipe-list-view": "^1.0.5",
    "react-native-switch-pro": "^0.4.6",
    "react-native-table-component": "^1.1.3",
    "react-native-vector-icons": "^4.5.0",
    "react-native-version-number": "^0.3.1",
    "react-native-voip-push-notification": "^1.1.1",
    "react-navigation": "^1.0.0-beta.27",
    "react-redux": "^5.0.6",
    "realm": "^2.2.6",
    "redux": "^3.7.2",
    "redux-api": "^0.11.2",
    "redux-logger": "^3.0.6",
    "redux-mock-store": "^1.5.1",
    "redux-persist": "^4.6.0-es",
    "redux-storage": "^4.1.2",
    "redux-storage-engine-reactnativeasyncstorage": "^1.0.5",
    "redux-thunk": "^2.2.0",
    "remote-redux-devtools": "^0.5.12",
    "snakecase-keys": "^1.1.0",
    "url": "^0.11.0",
    "uuid": "^3.1.0"
  },
  "devDependencies": {
    "babel-jest": "19.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "19.0.2",
    "react-test-renderer": "~15.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Not working on Android 7.1

This used to work and is no longer working on my Android devices. I'm on react-native 0.57.8. Anyone else having the same issues or know of a solution?

trouble getting started

After both link installing and manually installing this package, i cant seem to get past this error when i open a component which contains either the JS or JSX of keepawake. Please let me know if i can share any other helpful details.

undefined is not an object (evaluating '_reactNative.NativeModules.KCKeepAwake.activate')
activate
    index.js:12:36
componentWillMount
    index.js:25:4
<unknown>
    ReactCompositeComponent.js:468:16
measureLifeCyclePerf
    ReactCompositeComponent.js:85:11
performInitialMount
    ReactCompositeComponent.js:468:10
mountComponent
    ReactCompositeComponent.js:346:40
mountComponent
    ReactReconciler.js:62:6
mountChildren
    ReactMultiChild.js:264:10
initializeChildren
    ReactNativeBaseComponent.js:74:41
mountComponent
    ReactNativeBaseComponent.js:212:6
mountComponent
    ReactReconciler.js:62:6
performInitialMount
    ReactCompositeComponent.js:496:6
mountComponent
    ReactCompositeComponent.js:346:40
mountComponent
    ReactReconciler.js:62:6
performInitialMount
    ReactCompositeComponent.js:496:6
mountComponent
    ReactCompositeComponent.js:346:40
mountComponent
    ReactReconciler.js:62:6
_updateRenderedComponent
    ReactCompositeComponent.js:1000:8
_performComponentUpdate
    ReactCompositeComponent.js:944:34
updateComponent
    ReactCompositeComponent.js:847:8
performUpdateIfNecessary
    ReactCompositeComponent.js:735:8
performUpdateIfNecessary
    ReactReconciler.js:213:46
runBatchedUpdates
    ReactUpdates.js:171:6
perform
    Transaction.js:149:24
perform
    Transaction.js:149:24
perform
    ReactUpdates.js:96:8
flushBatchedUpdates
    ReactUpdates.js:199:26
closeAll
    Transaction.js:222:29
perform
    Transaction.js:163:24
batchedUpdates
    ReactDefaultBatchingStrategy.js:65:33
batchedUpdates
    ReactUpdates.js:111:41
_receiveRootNodeIDEvent
    ReactNativeEventEmitter.js:126:32
receiveTouches
    ReactNativeEventEmitter.js:213:8
__callFunction
    MessageQueue.js:242:47
<unknown>
    MessageQueue.js:108:26
guard
    MessageQueue.js:46:4
callFunctionReturnFlushedQueue
    MessageQueue.js:107:10

Android: Unable to build with react-native 0.53.0

I'm receiving the following error after upgrading to react-native 0.53.0. I don't understand this thoroughly but looks like there are multiple versions of some dependency. Would anyone know how to go about fixing this?

Execution failed for task ':app:transformDexWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/corbt/keepawake/BuildConfig;

Trouble with 0.43 (rc.4)

Having troubles testing out RN 0.43 (rc.4) with this package. It seems Xcode can't locate libKCKeepAwake-tvOS.a:

image

image

I've tried running react-native link as well as uninstalling/reinstalling this package. At this point, I'm still not sure if this has something to do with a breaking change in 43 or simply how I have things installed/linked/bundled on my end. Any ideas?

no such file or directory when linking

I'm getting this issue when attempting react-native link. Can you help me diagnose?

I have /com/app-name/MainApplication.java, not /com/company-name/app-name/MainApplication.java.

rnpm-install info Linking react-native-keep-awake android dependency
rnpm-install ERR! Something went wrong while linking. Error: ENOENT: no such file or directory, open '/Users/Me/Projects/app-name/android/app/src/main/java/com/company-name/app-name/MainApplication.java'
Please file an issue here: https://github.com/facebook/react-native/issues

ENOENT: no such file or directory, open '/Users/Me/Projects/app-name/android/app/src/main/java/com/company-name/app-name/MainApplication.java'

License file

Your package.json says you are licensed under MIT, but you don't currently have a LICENSE file.
Would it be possible to publish one please?

Cannot read property 'activate' of undefined IOS

Using:
"react-native": "0.61.4",
"react-native-keep-awake": "^4.0.0",

Installed the package, link it with react-native link, and it shows an error on iOS, however on Android works correctly.

How can I fix it?

Android - Build fail

Build fail on android

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve project :react-native-keep-awake.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-keep-awake: None of the consumable configurations have attributes.

Same problem of react-native-share/react-native-share#386 and PR #51 probably fixes this.

Trouble with RN 0.44.0

Using:

react-native-cli: 1.2.0
react-native: 0.44.0

Followed instructions for install and usage:

$ npm install --save react-native-keep-awake
$ react-native link

Included package:

import KeepAwake from 'react-native-keep-awake';

Added component to code (in render method):

<KeepAwake />

Nothing else and I get the following:
screen shot 2017-05-30 at 12 26 37 am

undefined is not an object (evaluating '_reactNative.NativeModules.KCKeepAwake.activate')
activate
    index.js:8:30
componentWillMount
    index.js:16:4
<unknown>
    ReactCompositeComponent.js:322:16
measureLifeCyclePerf
    ReactCompositeComponent.js:63:11
mountComponent
    ReactCompositeComponent.js:322:10
mountComponent
    ReactReconciler.js:57:6
mountChildren
    ReactMultiChild.js:277:10
initializeChildren
    ReactNativeBaseComponent.js:67:41
mountComponent
    ReactNativeBaseComponent.js:173:6
mountComponent
    ReactReconciler.js:57:6
performInitialMount
    ReactCompositeComponent.js:516:6
mountComponent
    ReactCompositeComponent.js:347:8
mountComponent
    ReactReconciler.js:57:6
performInitialMount
    ReactCompositeComponent.js:516:6
mountComponent
    ReactCompositeComponent.js:347:8
mountComponent
    ReactReconciler.js:57:6
mountChildren
    ReactMultiChild.js:277:10
initializeChildren
    ReactNativeBaseComponent.js:67:41
mountComponent
    ReactNativeBaseComponent.js:173:6
mountComponent
    ReactReconciler.js:57:6
performInitialMount
    ReactCompositeComponent.js:516:6
mountComponent
    ReactCompositeComponent.js:347:8
mountComponent
    ReactReconciler.js:57:6
updateChildren
    ReactChildReconciler.js:165:10
_reconcilerUpdateChildren
    ReactMultiChild.js:223:10
_updateChildren
    ReactMultiChild.js:366:6
updateChildren
    ReactMultiChild.js:352:25
receiveComponent
    ReactNativeBaseComponent.js:118:24
receiveComponent
    ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
    ReactCompositeComponent.js:1140:8
_updateRenderedComponent
    ReactCompositeComponent.js:1111:6
_performComponentUpdate
    ReactCompositeComponent.js:1032:36
updateComponent
    ReactCompositeComponent.js:915:8
receiveComponent
    ReactCompositeComponent.js:745:6
receiveComponent
    ReactReconciler.js:158:38
updateChildren
    ReactChildReconciler.js:142:10
_reconcilerUpdateChildren
    ReactMultiChild.js:223:10
_updateChildren
    ReactMultiChild.js:366:6
updateChildren
    ReactMultiChild.js:352:25
receiveComponent
    ReactNativeBaseComponent.js:118:24
receiveComponent
    ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
    ReactCompositeComponent.js:1140:8
_updateRenderedComponent
    ReactCompositeComponent.js:1111:6
_performComponentUpdate
    ReactCompositeComponent.js:1032:36
updateComponent
    ReactCompositeComponent.js:915:8
receiveComponent
    ReactCompositeComponent.js:745:6
receiveComponent
    ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
    ReactCompositeComponent.js:1140:8
_updateRenderedComponent
    ReactCompositeComponent.js:1111:6
_performComponentUpdate
    ReactCompositeComponent.js:1032:36
updateComponent
    ReactCompositeComponent.js:915:8
performUpdateIfNecessary
    ReactCompositeComponent.js:770:8
performUpdateIfNecessary
    ReactReconciler.js:210:46
runBatchedUpdates
    ReactUpdates.js:146:6
perform
    Transaction.js:150:24
perform
    Transaction.js:150:24
perform
    ReactUpdates.js:78:6
flushBatchedUpdates
    ReactUpdates.js:164:24
closeAll
    Transaction.js:221:29
perform
    Transaction.js:163:24
batchedUpdates
    ReactDefaultBatchingStrategy.js:61:33
batchedUpdates
    ReactUpdates.js:92:41
batchedUpdates
    ReactGenericBatching.js:38:29
batchedUpdatesWithControlledComponents
    ReactGenericBatching.js:51:26
_receiveRootNodeIDEvent
    ReactNativeEventEmitter.js:105:40
receiveTouches
    ReactNativeEventEmitter.js:193:8
__callFunction
    MessageQueue.js:250:47
<unknown>
    MessageQueue.js:101:26
__guard
    MessageQueue.js:218:6
callFunctionReturnFlushedQueue
    MessageQueue.js:100:17

Support for KeepAwake only when device is charging

Not sure if this has been suggested before, but it might be nice to add support for the ability to keep the screen from going to sleep only if the device is currently being charged. I don't think RN has any built-in support for detecting that so currently you'd need to either pull in a separate extension, or fork and modify this one to support it.

Not working on iPhone X

Hi, I am using this package on my RN project. iPhone 6s, iPad is working but not working on iPhone X.
Here is my code and device info.

"react-native-keep-awake": "^4.0.0",

componentDidMount() {
   ...
    KeepAwake.activate();
}
React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (4) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
      Memory: 47.43 MB / 4.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.0 - /usr/local/bin/node
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.1, 25.0.2, 26.0.2, 27.0.3, 28.0.3
        System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.0.0 => 16.6.0
      react-native: ^0.57.8 => 0.57.8
    npmGlobalPackages:
      react-native-cli: 2.0.1

file

Anyone have seen this kind of issue and using iPhone X or earlier version?

Build file 'C:\Users\Xiaojiju\Desktop\YJJ2.0\node_modules\react-native-keep-awake\android\build.gradle' line: 3

to be honest,it beats me!!

`NDK is missing a "platforms" directory.ing dependencies ':app:_debugApk'
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Xiaojiju\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\Users\Xiaojiju\Desktop\YJJ2.0\node_modules\react-native-keep-awake\android\build.gradle' line: 3

  • What went wrong:
    A problem occurred evaluating project ':react-native-keep-awake'.

Could not find method google() for arguments [] on repository container.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED`

and this is the content which showed path by error

`buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()

}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}

}

apply plugin: 'com.android.library'

def _ext = rootProject.ext

def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 27
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 27

android {
compileSdkVersion _compileSdkVersion
buildToolsVersion _buildToolsVersion

defaultConfig {
    minSdkVersion _minSdkVersion
    targetSdkVersion _targetSdkVersion
    versionCode 1
    versionName "1.0"
}
lintOptions {
    abortOnError false
}

}

dependencies {
//noinspection GradleDynamicVersion
compile "com.facebook.react:react-native:${_reactNativeVersion}"
}
`
did u get the excepotion? pls help me!

Add to the depreciation notice to npm

Hey,
The official alternative is
https://www.npmjs.com/package/expo-keep-awake

Now that we have non-expo two alternatives
https://www.npmjs.com/package/@sayem314/react-native-keep-awake
https://github.com/unsw-gsbme/react-native-keep-awake

It would be good to add a depreciation notice to the actual npm package. as we only found out by chance.

I personally don't even mind if the official depreciation notice points to the expo one, but something to start the moving. it still a downloaded by a lot of people.

ld: library not found for -lKCKeepAwake-tvOS

Hi,

I am getting an error (ld: library not found for -lKCKeepAwake-tvOS) during the project build after I add KeepAwake to the project. I don't need a tvOS version of course but it expects the lib to be present. Any ideas how to get rid of this error?

Thanks in advance.

Always active for ios

I am having an issue that the app is always awake once I include this package into my project for ios. It works fine for android. I don't even have to call

<KeepAwake />
or

KeepAwake.activate();

And it will remain on. In fact, even if I only call

KeepAwake.deactivate();

it will remain on.

Does anyone have any thoughts or suggestions here?

Android build tools to 25.0.2

Description

Please update the Android build tools to 25.0.2 in build.gradle

Additional Information

react-native version: 0.46.2

Error when release APK

Task :app:transformNativeLibsWithStripDebugSymbolForRelease
Unable to strip library '/Users/circledoo/Documents/Project/Mobile/AdiraFinance/android/app/build/intermediates/transforms/mergeJniLibs/release/0/lib/
armeabi/libicu_common.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library '/Users/circledoo/Documents/Project/Mobile/AdiraFinance/android/app/build/intermediates/transforms/mergeJniLibs/release/0/lib/
armeabi/libimagepipeline.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library '/Users/circledoo/Documents/Project/Mobile/AdiraFinance/android/app/build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi/libucrop.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
warning: string 'ucrop_error_input_data_is_absent' has no default translation.
warning: string 'ucrop_mutate_exception_hint' has no default translation.
/Users/circledoo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/6c2cd1c502c2956a696b8b734e1a98a7/res/values-v24/values-v24.xml:3:5-157:
AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Color
ed'.

/Users/circledoo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/6c2cd1c502c2956a696b8b734e1a98a7/res/values-v24/values-v24.xml:4:5-135:
AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

/Users/circledoo/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/6c2cd1c502c2956a696b8b734e1a98a7/res/values-v26/values-v26.xml:13:5-16:13: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

Task :react-native-keep-awake:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-keep-awake:verifyReleaseResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Typings not released

I see the TypeScript typings were added to this repo, however, they are not a part of the released package. Would a 4.0.1 version be pushed out with the typings included please?

RN 0.60+ support and Android X

We are looking to update our project to the latest version of RN (v0.60.5) and going through the docs I could not find anything on updating.

All I know is there are breaking changes with 0.60 in regards to Android X and I was wondering if this is in the pipeline somewhere that may be addressed?

Has anyone run into any issues with v0.60+?

Thanks

Duplicate symbols for architecture arm64 when building for iOS

I performed react-native link and noticed that none of the steps mentioned in the manual installation process were done. And when I built the app and ran on my phone, I got the following error -

image uploaded from ios

Then I followed the manual process and then I'm getting the following error when building -

duplicate symbol _OBJC_CLASS_$_KCKeepAwake in:
    /Users/home/Library/Developer/Xcode/DerivedData/Project-ebmpighnxudjkvaximcrjfawqrjk/Build/Products/Debug-iphoneos/react-native-keep-awake/libreact-native-keep-awake.a(KCKeepAwake.o)
    /Users/home/Library/Developer/Xcode/DerivedData/Project-ebmpighnxudjkvaximcrjfawqrjk/Build/Products/Debug-iphoneos/libKCKeepAwake.a(KCKeepAwake.o)
duplicate symbol _OBJC_METACLASS_$_KCKeepAwake in:
    /Users/home/Library/Developer/Xcode/DerivedData/Project-ebmpighnxudjkvaximcrjfawqrjk/Build/Products/Debug-iphoneos/react-native-keep-awake/libreact-native-keep-awake.a(KCKeepAwake.o)
    /Users/home/Library/Developer/Xcode/DerivedData/Project-ebmpighnxudjkvaximcrjfawqrjk/Build/Products/Debug-iphoneos/libKCKeepAwake.a(KCKeepAwake.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Appreciate help with this. Thanks!

Undocumented bheavior on app state transition

If I had done KeepAwake.activate(), then the app was transitioned to the background (user focused another app). KeepAwake deactivates. And then when user returns to the app, I have to re-enable the keep awake. If anyone else can confirm this, we should document it.

KeepAwake.activate() not working when running the app in Xcode. Is it worth mentioning this in readme?

For me, the KeepAwake.activate() call did not have any effect and the screen went to sleep.

This happened on iOS only (tested on iPad Air 2, iPhone 6 and iPhone XS) and I realised that when running the app from Xcode (running by pressing play button), then the plugin doesn't seem to work.

As soon as I don't run from Xcode and just start the app from the device the screen does not go to sleep.

If anyone else has experienced this too, then please let me know.

If it's happening for others too, then I would be happy to make a PR with an update to the readme to mention that the plugin doesn't work when running from Xcode.

My setup:

  • react-native 0.57.2
  • Xcode 10.2.1
  • iOS 11 & 12 (iPhone 6 running iOS 11)
  • react-native-keep-awake 4.0.0

Does not compile with RN 0.47

In RN 0.47 there is no more createJSModules method in ReactPackage interface. Because of this KCKeepAwakePackage does not compile. To make it backwards compatible, just remove @OverRide.

node_modules/react-native-keep-awake/android/src/main/java/com/corbt/keepawake/KCKeepAwakePackage.java:23: error: method does not override or implement a method from a supertype
    @Override

ReactPackage.java

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.