{"id":13906044,"url":"https://github.com/apache/cordova-plugin-battery-status","last_synced_at":"2025-04-14T15:48:26.607Z","repository":{"id":9085292,"uuid":"10860590","full_name":"apache/cordova-plugin-battery-status","owner":"apache","description":"Apache Cordova Battery Status Plugin","archived":false,"fork":false,"pushed_at":"2024-10-26T03:21:04.000Z","size":359,"stargazers_count":101,"open_issues_count":8,"forks_count":147,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-10T11:58:42.623Z","etag":null,"topics":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"latest_commit_sha":null,"homepage":"https://cordova.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2013-06-22T07:00:13.000Z","updated_at":"2024-10-26T03:21:08.000Z","dependencies_parsed_at":"2024-11-16T16:27:51.016Z","dependency_job_id":"c7012887-7982-4c69-a972-264d8f45ba6d","html_url":"https://github.com/apache/cordova-plugin-battery-status","commit_stats":{"total_commits":223,"total_committers":52,"mean_commits":4.288461538461538,"dds":0.7533632286995515,"last_synced_commit":"2a726ca10f997bb6b5dd35a30543247c6d42e4d6"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-battery-status","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-battery-status/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-battery-status/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-plugin-battery-status/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/cordova-plugin-battery-status/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248666598,"owners_count":21142271,"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":["android","cordova","hacktoberfest","ios","java","javascript","library","mobile","nodejs","objective-c"],"created_at":"2024-08-06T23:01:28.447Z","updated_at":"2025-04-14T15:48:26.587Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","readme":"---\ntitle: Battery Status\ndescription: Get events for device battery level.\n---\n\u003c!--\n# license: Licensed to the Apache Software Foundation (ASF) under one\n#         or more contributor license agreements.  See the NOTICE file\n#         distributed with this work for additional information\n#         regarding copyright ownership.  The ASF licenses this file\n#         to you under the Apache License, Version 2.0 (the\n#         \"License\"); you may not use this file except in compliance\n#         with the License.  You may obtain a copy of the License at\n#\n#           http://www.apache.org/licenses/LICENSE-2.0\n#\n#         Unless required by applicable law or agreed to in writing,\n#         software distributed under the License is distributed on an\n#         \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#         KIND, either express or implied.  See the License for the\n#         specific language governing permissions and limitations\n#         under the License.\n--\u003e\n\n# cordova-plugin-battery-status\n\n[![Android Testsuite](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-battery-status/actions/workflows/lint.yml)\n\nThis plugin provides an implementation of an old version of the [Battery Status Events API][w3c_spec]. It adds the following three events to the `window` object:\n\n* batterystatus\n* batterycritical\n* batterylow\n\nApplications may use `window.addEventListener` to attach an event listener for any of the above events after the `deviceready` event fires.\n\n## Installation\n\n    cordova plugin add cordova-plugin-battery-status\n\n## Status object\n\nAll events in this plugin return an object with the following properties:\n\n- __level__: The battery charge percentage (0-100). _(Number)_\n- __isPlugged__: A boolean that indicates whether the device is plugged in. _(Boolean)_\n\n## batterystatus event\n\nFires when the battery charge percentage changes by at least 1 percent, or when the device is plugged in or unplugged. Returns an [object][status_object] containing battery status.\n\n### Example\n\n    window.addEventListener(\"batterystatus\", onBatteryStatus, false);\n\n    function onBatteryStatus(status) {\n        console.log(\"Level: \" + status.level + \" isPlugged: \" + status.isPlugged);\n    }\n\n### Supported Platforms\n\n- iOS\n- Android\n- Browser (Chrome, Firefox, Opera)\n\n### Quirks: Android\n\n**Warning**: the Android implementation is greedy and prolonged use will drain the device's battery.\n\n## batterylow event\n\nFires when the battery charge percentage reaches the low charge threshold. This threshold value is device-specific. Returns an [object][status_object] containing battery status.\n\n### Example\n\n    window.addEventListener(\"batterylow\", onBatteryLow, false);\n\n    function onBatteryLow(status) {\n        alert(\"Battery Level Low \" + status.level + \"%\");\n    }\n\n### Supported Platforms\n\n- iOS\n- Android\n- Browser (Chrome, Firefox, Opera)\n\n## batterycritical event\n\nFires when the battery charge percentage reaches the critical charge threshold. This threshold value is device-specific. Returns an [object][status_object] containing battery status.\n\n### Example\n\n    window.addEventListener(\"batterycritical\", onBatteryCritical, false);\n\n    function onBatteryCritical(status) {\n        alert(\"Battery Level Critical \" + status.level + \"%\\nRecharge Soon!\");\n    }\n\n### Supported Platforms\n\n- iOS\n- Android\n- Browser (Chrome, Firefox, Opera)\n\n\n[w3c_spec]: https://www.w3.org/TR/battery-status/\n[status_object]: #status-object\n","funding_links":[],"categories":["JavaScript","Index"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-battery-status","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcordova-plugin-battery-status","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-plugin-battery-status/lists"}