{"id":20815409,"url":"https://github.com/vineyardbovines/react-native-android-wake-lock","last_synced_at":"2025-05-07T12:21:51.939Z","repository":{"id":38902885,"uuid":"254928649","full_name":"vineyardbovines/react-native-android-wake-lock","owner":"vineyardbovines","description":"Native Module for setting a wake lock on an Android device","archived":false,"fork":false,"pushed_at":"2023-12-15T14:37:04.000Z","size":2667,"stargazers_count":8,"open_issues_count":22,"forks_count":18,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-21T17:23:39.063Z","etag":null,"topics":["native-module","react-native","wake-lock"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vineyardbovines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-11T18:20:27.000Z","updated_at":"2023-11-17T08:48:20.000Z","dependencies_parsed_at":"2024-10-15T09:30:02.790Z","dependency_job_id":"ec8f926c-d433-40c4-9fcb-a6c5fc9760df","html_url":"https://github.com/vineyardbovines/react-native-android-wake-lock","commit_stats":null,"previous_names":["vineyardbovines/react-native-android-wake-lock","gretzky/react-native-android-wake-lock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vineyardbovines%2Freact-native-android-wake-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vineyardbovines%2Freact-native-android-wake-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vineyardbovines%2Freact-native-android-wake-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vineyardbovines%2Freact-native-android-wake-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vineyardbovines","download_url":"https://codeload.github.com/vineyardbovines/react-native-android-wake-lock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252874208,"owners_count":21817780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["native-module","react-native","wake-lock"],"created_at":"2024-11-17T21:23:01.967Z","updated_at":"2025-05-07T12:21:51.912Z","avatar_url":"https://github.com/vineyardbovines.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-android-wake-lock\n\nNative Module for setting a [wake lock](https://developer.android.com/training/scheduling/wakelock) on an Android device. Utilizes both `PowerManager` and `WifiManager`.\n\n## Installation\n\n**Note:** This package requires React Native \u003e=0.60.\n\nInstall with npm/yarn.\n\n```bash\nnpm install react-native-android-wake-lock --save\n// or\nyarn add react-native-wake-lock\n```\n\nSince this package requires RN 0.60 or higher, this package will be linked automatically. If you run into an issue, you can try `react-native link react-native-android-wake-lock`.\n\n## Usage\n\nMake sure to request the wake lock permission. Add the following inside the project manifest (`android/app/src/main/AndroidManifest.xml`):\n\n```xml\n\u003cuses-permission android:name=\"android.permission.WAKE_LOCK\" /\u003e\n```\n\nThis module exposes 2 possible methods for accessing the wake lock: via an interface object or a React hook. Depending on your use case, one or the other should suffice.\n\n```js\nimport React from \"react\";\nimport { WakeLockInterface, useWakeLock } from \"react-native-android-wake-lock\";\n\n// the interface exposes all 3 (async) methods\nconst isWakeLocked = WakeLockInterface.isWakeLocked();\n// these 2 aren't necessary if you're using the hook\nconst setWakeLock = WakeLockInterface.setWakeLock();\nconst releaseWakeLock = WakeLockInterface.releaseWakeLock();\n\n// you can also use the hook to set/release a wake lock on component mount/unmount\nconst Component = () =\u003e {\n  const [wakeLocked, setWakeLocked] = useState(isWakeLocked);\n\n  // you can use the `isWakeLocked` method from the interface to check whether or not the wake lock is set\n  useEffect(() =\u003e {\n    console.log(wakeLocked);\n  }, [wakeLocked]);\n\n  useWakeLock();\n\n  return \u003cView /\u003e;\n};\n```\n\n## API\n\nThe interface has 3 methods:\n\n- **`setWakeLock(): Promise\u003cboolean\u003e`** - sets both the WakeLock and WifiLock\n- **`releaseWakeLock(): Promise\u003cboolean\u003e`** - releases both the WakeLock and WifiLock\n- **`isWakeLocked(): Promise\u003cboolean\u003e`** - whether or not the wake/wifi locks are held\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvineyardbovines%2Freact-native-android-wake-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvineyardbovines%2Freact-native-android-wake-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvineyardbovines%2Freact-native-android-wake-lock/lists"}