-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New non expo fork with hooks support! #74
Comments
Great work @sayem314. Unfortunately I can't get it to work. I am using react-native 0.61.5 and can't get it to work neither on ios nor android. Am I missing something? I've added the useKeepAwake() hook at the top of my function component. |
What version of react-native are you on? @Infoto I have apps running on testflight and android alpha, working solid. |
Hey @Infoto sorry, I was in a group conference call when I read and replied on your comment. I see you are on 0.61.5 which should work properly. Can you please give me a code snapshot of the way you are using? Also, did you use |
Hi, thanks for your fast response. I just tried it in App.js but still nothing. Here is the code: export default () => {
useKeepAwake();
const [client, setClient] = useState();
useEffect(() => {
setClient(new ApolloClient({
connectToDevTools: true,
link: errorLink.concat(authMiddleware.concat(link)),
cache,
typeDefs,
resolvers
}));
}, []);
const {showOverlay} = useOverlay();
if (!client) {
return <LoadingScreen/>
}
return (
<NativeRouter>
<ApolloProvider client={client}>
<RootScreen/>
</ApolloProvider>
<DeepLinking/>
</NativeRouter>
);
} I've installed the pod successfully and it has been added to the
I've also built it for production and tried but still the screen turns off after 30 seconds. |
Weird, not sure what's wrong actually. Maybe enable debug mode and see if there are any helpful logs. |
The method declarations in index.js were empty, therefore I had to import it from either .ios or .android which is not that convenient. Fixes issue corbt#74.
Hi @sayem314 I fixed it and added a PR. |
but why? just use expo-keep-awake and contribute to that |
@brentvatne expo-keep-awake require you to use react-native-unimodules, I was unsuccessful to use it multiple times. And it's bloated > https://github.com/expo/expo/blob/master/packages/react-native-unimodules/package.json#L38-L58 |
trying to avoid installing unimodules... unnecessary library for the sake of loading another library. |
Did you find any solution? to not installing uni modules |
unimodules adds a minimal amount of code to your built project, the interface files are just headers that are a few kb and won't have an impact on your compiled binary. and yes if you just want this keep awake library then it's probably a lot to install, but you're also building an app that has more than just a screen that stays on, i imagine, in which case you'd likely benefit from the range of other expo packages available. installation instructions aren't hard to follow, and you only have to do it once. alternatively if you're creating a new project just run the reason unimodules exists is to solve the issue of inter-module dependencies. expo-camera can leverage expo-permissions, expo-file-system, and others rather than having to rebuild all of permission handling and file system code in an ad-hoc and usually buggy way. so there isn't "unnecessary" - it solves a real problem that the community generally ignores, unfortunately. |
Hi @sayem314 - I'm interested in using your fork, but would feel more comfortable if you had issues enabled. Can you enable them? Here's a StackOverflow answer walking through how to do it: @brentvatne I was interested in the expo version for a bit, but unfortunately the installation was not as straightforward as I had hoped. I could not install unimodules without fully integrating expo into my project - which is buckets more commitment than I'm willing to make for a single 3rd party library. |
Might not be as pretty with the hooks but I found this library which does the same and has a bit more stars and heritage? @Infoto I guess it is not working as the native code is not linked to the project yet? There is nothing mentioned to call |
FYI This lib worked fine for me and writing my own hook was not much of a hassle either. import { useEffect } from 'react';
import IdleTimerManager from 'react-native-idle-timer';
function useKeepAwake() {
useEffect(() => {
IdleTimerManager.setIdleTimerDisabled(true);
return () => IdleTimerManager.setIdleTimerDisabled(false);
}, []);
}
export default useKeepAwake; |
@brentvatne some of us don't use expo, and actively avoid it. It has a lot of buy in. We just tried to add the expo-keep-awake. It required the change of 12 project files, and added deps on to large number of what we can see mostly useless unrelated files to keeping a phone awake. So we are moving to an in house solution seeing as this is basically one line. Good to see this being forked. Maybe we might migrate to this new fork, once it gets more attention. We are basically rewriting this using https://github.com/callstack/react-native-builder-bob |
@jahead - i get that, there is a one time cost to setting things up. up to you. |
@jahead Will you be sharing your in-house solution with the community and is there any ETA for the project? |
Oh sorry, I missed this ping, yes, we can. if the community would like it |
@corbt it would be nice to get the namespace in npm for this, otherwise it would have to listed under the unsw-gsbme scope, which is weird but will work. |
Okay done! https://www.npmjs.com/package/@unsw-gsbme/react-native-keep-awake https://github.com/unsw-gsbme/react-native-keep-awake Sorry it took us a day, had to clear it up a bit, and we migrated to github actions from our internal azure pipelines. |
@brentvatne I know you are a busy person, But maybe you could take a crack at #77 and you would probably have a better chance? |
He hasn't enabled issues since then. I have written an email to him now. |
@pke the unsw-gsbme package does have issues enabled, and the team at unsw still actively use it. I no longer work there, but i still have access to their open source work, so if there is interest I can take a pass this weekend and update it. We also accept PRs. |
I don't have native knowledge but I have forked this and added expo-keep-awake syntax support as well as web export to prevent errors on the web.
https://www.npmjs.com/package/@sayem314/react-native-keep-awake
The text was updated successfully, but these errors were encountered: