{"id":13777073,"url":"https://github.com/williambout/react-native-proximity","last_synced_at":"2025-05-11T10:31:35.686Z","repository":{"id":48876298,"uuid":"57891612","full_name":"williambout/react-native-proximity","owner":"williambout","description":":iphone: A React Native wrapper that provides access to the proximity sensor on iOS and Android.","archived":true,"fork":false,"pushed_at":"2021-07-07T13:20:15.000Z","size":2608,"stargazers_count":211,"open_issues_count":16,"forks_count":67,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-16T20:56:41.589Z","etag":null,"topics":["android","ios","iphone","proximity-sensor","react-native","sensor"],"latest_commit_sha":null,"homepage":"","language":"Java","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/williambout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-02T13:19:21.000Z","updated_at":"2024-06-07T11:44:54.000Z","dependencies_parsed_at":"2022-09-12T14:26:21.270Z","dependency_job_id":null,"html_url":"https://github.com/williambout/react-native-proximity","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williambout%2Freact-native-proximity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williambout%2Freact-native-proximity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williambout%2Freact-native-proximity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williambout%2Freact-native-proximity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williambout","download_url":"https://codeload.github.com/williambout/react-native-proximity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551815,"owners_count":21926368,"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","ios","iphone","proximity-sensor","react-native","sensor"],"created_at":"2024-08-03T18:00:37.254Z","updated_at":"2025-05-11T10:31:32.804Z","avatar_url":"https://github.com/williambout.png","language":"Java","funding_links":[],"categories":["\u003ca name=\"Motion-Sensor:-Native-Modules\"\u003eMotion Sensor: Native Modules\u003c/a\u003e"],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/react-native-proximity.svg)](https://badge.fury.io/js/react-native-proximity)\r\n\r\n# react-native-proximity\r\n\r\nA React Native wrapper that provides access to the state of the proximity sensor for iOS and Android.\r\n\r\n![](https://github.com/williambout/react-native-proximity/raw/master/demo.gif)\r\n\r\n*Usage of react-native-proximity and scrollview.*\r\n\r\n## Getting Started\r\n\r\n- Install the library \r\n```shell\r\nnpm install --save react-native-proximity\r\n```\r\n- Link the library \r\n```shell\r\nreact-native link react-native-proximity\r\n```\r\n\r\n## Usage\r\n\r\nImport the library\r\n\r\n```javascript\r\nimport Proximity from 'react-native-proximity';\r\n```\r\n\r\n### addListener(callback)\r\nThe callback function returns an object with *proximity* and *distance* properties. If *proximity* is true, it means the device is close to an physical object. *distance* is only supported in Android.\r\n```javascript\r\ncomponentDidMount(){\r\n Proximity.addListener(this._proximityListener);\r\n},\r\n\r\n/**\r\n * State of proximity sensor\r\n * @param {object} data\r\n */\r\n _proximityListener(data) {\r\n   this.setState({\r\n     proximity: data.proximity,\r\n     distance: data.distance // Android-only \r\n   });\r\n },\r\n```\r\n\r\n### removeListener(callback)\r\n\r\n```javascript\r\ncomponentWillUnmount() {\r\n  Proximity.removeListener(this._proximityListener);\r\n},\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliambout%2Freact-native-proximity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliambout%2Freact-native-proximity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliambout%2Freact-native-proximity/lists"}