{"id":4454,"url":"https://github.com/priteshrnandgaonkar/react-native-call-detection","last_synced_at":"2025-04-12T23:41:32.492Z","repository":{"id":37677787,"uuid":"94617244","full_name":"priteshrnandgaonkar/react-native-call-detection","owner":"priteshrnandgaonkar","description":"react-native package to detect call states","archived":false,"fork":false,"pushed_at":"2023-09-13T21:09:25.000Z","size":182233,"stargazers_count":194,"open_issues_count":40,"forks_count":113,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-08T20:48:50.489Z","etag":null,"topics":["react-native"],"latest_commit_sha":null,"homepage":null,"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/priteshrnandgaonkar.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}},"created_at":"2017-06-17T10:40:07.000Z","updated_at":"2025-02-10T21:11:16.000Z","dependencies_parsed_at":"2024-01-08T01:03:13.067Z","dependency_job_id":"0fbd1583-14e7-4c38-a966-9e3e08e91f5a","html_url":"https://github.com/priteshrnandgaonkar/react-native-call-detection","commit_stats":{"total_commits":157,"total_committers":20,"mean_commits":7.85,"dds":0.2993630573248408,"last_synced_commit":"a74ddb3cd4adeddf44bae58b09233bd219702aeb"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/priteshrnandgaonkar%2Freact-native-call-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/priteshrnandgaonkar%2Freact-native-call-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/priteshrnandgaonkar%2Freact-native-call-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/priteshrnandgaonkar%2Freact-native-call-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/priteshrnandgaonkar","download_url":"https://codeload.github.com/priteshrnandgaonkar/react-native-call-detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647254,"owners_count":21139081,"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":["react-native"],"created_at":"2024-01-05T20:17:13.092Z","updated_at":"2025-04-12T23:41:32.461Z","avatar_url":"https://github.com/priteshrnandgaonkar.png","language":"Java","funding_links":[],"categories":["Components"],"sub_categories":["Utils \u0026 Infra"],"readme":"## React Native Call Detection 🎉 🎊\n[![npm version](https://badge.fury.io/js/react-native-call-detection.svg)](https://badge.fury.io/js/react-native-call-detection)\n\nThis package helps to detect different call states like `Incoming`, `Disconnected`, `Dialing` and `Connected` for iOS. For android, this package will give following states, `Offhook`, `Incoming`, `Disconnected` and `Missed`. In the case of `Incoming` for android, the package will also provide with the incoming phone number.\n\n## Installation\n\nAdd the package to your react-native project in the following way\n\n```shell\nyarn add react-native-call-detection\n\n```\n\n## Integrate into an Expo managed project\n\n1. Install `expo-dev-client`:\n\n```shell\nexpo install expo-dev-client\n```\n\n2. Add `react-native-call-detection` into the `plugins` array inside the `app.json` file of your app:\n\n```shell\n\"plugins\": [\n  [\"react-native-call-detection\"],\n],\n```\n\n### For Android:-\nAutolinking should work without manual changes\n\n## Usage\nThere are different hooks that you may get depending on the platform. Since for android you could also request the package to provide you with phone number of the caller, you will have to provide the necessary request message and the corresponding error callback. The package will request for `READ_PHONE_STATE` permission in android.\n\nIts really easy to setup the package. Have a look at the following code snippet\n\n``` javascript\nimport CallDetectorManager from 'react-native-call-detection'\n\nstartListenerTapped() {\n\tthis.callDetector = new CallDetectorManager((event, phoneNumber)=\u003e {\n\t// For iOS event will be either \"Connected\",\n\t// \"Disconnected\",\"Dialing\" and \"Incoming\"\n\n\t// For Android event will be either \"Offhook\",\n\t// \"Disconnected\", \"Incoming\" or \"Missed\"\n\t// phoneNumber should store caller/called number\n\n\n\tif (event === 'Disconnected') {\n\t// Do something call got disconnected\n\t}\n\telse if (event === 'Connected') {\n\t// Do something call got connected\n\t// This clause will only be executed for iOS\n\t}\n\telse if (event === 'Incoming') {\n\t// Do something call got incoming\n\t}\n\telse if (event === 'Dialing') {\n\t// Do something call got dialing\n\t// This clause will only be executed for iOS\n\t}\n\telse if (event === 'Offhook') {\n\t//Device call state: Off-hook.\n\t// At least one call exists that is dialing,\n\t// active, or on hold,\n\t// and no calls are ringing or waiting.\n\t// This clause will only be executed for Android\n\t}\n\telse if (event === 'Missed') {\n    \t// Do something call got missed\n    \t// This clause will only be executed for Android\n  }\n},\nfalse, // if you want to read the phone number of the incoming call [ANDROID], otherwise false\n()=\u003e{}, // callback if your permission got denied [ANDROID] [only if you want to read incoming number] default: console.error\n{\ntitle: 'Phone State Permission',\nmessage: 'This app needs access to your phone state in order to react and/or to adapt to incoming calls.'\n} // a custom permission request message to explain to your user, why you need the permission [recommended] - this is the default one\n)\n}\n\nstopListenerTapped() {\n\tthis.callDetector \u0026\u0026 this.callDetector.dispose();\n}\n\n```\n\nDont forget to call `dispose` when you don't intend to use call detection, as it will avoid memory leakages.\n\nExample project can be used to test out the package. In the example project update the `HomeComponent.js` with the phone number to call\n\n```javascript\n  callFriendTapped() {\n  // Add the telephone num to call\n    Linking.openURL('tel:5555555555')\n      .catch(err =\u003e {\n        console.log(err)\n      });\n  }\n```\n\n### How to run an example\n\n1. Install `node` and `watchman`\n\n\t```\n\tbrew install node\n\tbrew install watchman\n\n\t```\n\n2. `yarn`\n\n    Install `yarn` from `npm`.\n\n        npm i -g yarn\n\n3. Xcode\n\n    Install it from the App Store.\n\n4. React Native Debugger\n\n    This is an electron app that bundles react devtools, redux devtools and chrome devtools configured for use with react-native.\n\n        brew cask install react-native-debugger\n5. Once you have done all the above steps, navigate to `CallDetectionExample` folder and run `yarn` or `npm install`, it will fetch all the dependencies in the `node_modules` folder.\n\n6. Run the packager\n\t`npm start`\n\n7. Update the mobile number of your friend in [`HomeComponent.js`](CallDetectionExample/src/HomeComponent.js)\n\n\n\t```javascript\n\t callFriendTapped() {\n\t // Add the telephone number\n    \tLinking.openURL('tel:5555555555')\n      .catch(err =\u003e {\n        console.log(err)\n      });\n  \t }\n\n\t```\n\n7. To run the example on iOS from terminal type\n\t`react-native run-ios` (This will open the simulator, since simulator doesnt have the support for calling I will advice you to connect your iOS device and the follow the below procedure for running the app through xcode)\n\n\tor you can also run the app from xcode, for that, open `/CallDectionExample/ios/CallDetectionExample.xcodeproj` in xcode and run on the device.\n\n8. To run the example on android, connect any android device to your mac then follow the below steps\n\t1. Navigate to `android` folder(./CallDectionExample/android/) folder and then run `adb reverse tcp:8081 tcp:8081`\n\t2. Navigate back to example directory(CallDectionExample) and then run\n\t`react-native run-android`\n\nFor any problems and doubt raise an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpriteshrnandgaonkar%2Freact-native-call-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpriteshrnandgaonkar%2Freact-native-call-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpriteshrnandgaonkar%2Freact-native-call-detection/lists"}