{"id":16748386,"url":"https://github.com/gnestor/react-native-silent-switch","last_synced_at":"2025-10-27T22:17:57.107Z","repository":{"id":54219848,"uuid":"57435495","full_name":"gnestor/react-native-silent-switch","owner":"gnestor","description":"Detect the iOS silent switch using React Native","archived":false,"fork":false,"pushed_at":"2021-03-02T22:54:46.000Z","size":30,"stargazers_count":19,"open_issues_count":6,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T05:43:58.440Z","etag":null,"topics":["ios","ios-silent-switch","mute","react-native","silent-switch"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnestor.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-04-30T09:27:04.000Z","updated_at":"2023-09-08T17:09:50.000Z","dependencies_parsed_at":"2022-08-13T09:30:34.308Z","dependency_job_id":null,"html_url":"https://github.com/gnestor/react-native-silent-switch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnestor%2Freact-native-silent-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnestor%2Freact-native-silent-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnestor%2Freact-native-silent-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnestor%2Freact-native-silent-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnestor","download_url":"https://codeload.github.com/gnestor/react-native-silent-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880350,"owners_count":20525507,"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":["ios","ios-silent-switch","mute","react-native","silent-switch"],"created_at":"2024-10-13T02:12:32.613Z","updated_at":"2025-10-27T22:17:52.065Z","avatar_url":"https://github.com/gnestor.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Silent Switch\n\nDetect the iOS silent switch using React Native\n\n## Install\n\n### Using [rnpm](https://github.com/rnpm/rnpm)\n\n* Install: `rnpm install react-native-silent-switch`\n* Add `mute.caf` from the library to your project bundle\n  * Project Navigator \u003e [YOUR PROJECT NAME] \u003e Build Phases \u003e Copy Bundle Resources\n* Verify that `$(SRCROOT)/../../node_modules/react-native/React` is in the library's header search paths for both Debug and Release schemes\n    * Project Navigator \u003e RCTSilentSwitch.xcodeproj \u003e Build Settings \u003e Header Search Paths \u003e Debug AND Release\n\n### Manually\n\n* Install: `npm install react-native-silent-switch --save`\n* Link library in Xcode: See [React Native guide](https://facebook.github.io/react-native/docs/linking-libraries-ios.html)\n* Add `mute.caf` from the library to your project bundle\n  * Project Navigator \u003e [YOUR PROJECT NAME] \u003e Build Phases \u003e Copy Bundle Resources\n* Verify that `$(SRCROOT)/../../node_modules/react-native/React` is in the library's header search paths for both Debug and Release schemes\n  * Project Navigator \u003e RCTSilentSwitch.xcodeproj \u003e Build Settings \u003e Header Search Paths \u003e Debug AND Release\n\n## Usage\n\n```js\nimport SilentSwitch from 'react-native-silent-switch'\n```\n\n```js\ncomponentDidMount() {\n  // Listen for silent switch toggle events\n  SilentSwitch.addEventListener(silent =\u003e {\n    // When switched to silent, the callback will return true. When switched from silent, it will return false.\n    if (silent) this.navigator.push({id: 'SilentAlert'})\n  })\n}\n\ncomponentWillUnmount() {\n  SilentSwitch.removeEventListener()\n}\n```\n\n## Usage with [react-native-statusbar-alert](https://github.com/gnestor/react-native-statusbar-alert)\n\n```js\nimport SilentSwitch from 'react-native-silent-switch'\nimport StatusBarAlert from 'react-native-statusbar-alert'\n```\n\n```js\ncomponentDidMount() {\n  SilentSwitch.addEventListener(silent =\u003e {\n    if (silent) {\n      this.setState({\n        alerts: [{\n          message: 'Silent Switch ON',\n          onPress: () =\u003e this.navigator.push({id: 'SilentAlert'})\n        }, ...this.state.alerts]\n      })\n    } else {\n      this.setState({\n        alerts: this.state.alerts.filter(alert =\u003e alert.message !== 'Silent Switch ON')\n      })\n    }\n  })\n}\n\ncomponentWillUnmount() {\n  SilentSwitch.removeEventListener()\n}\n\nrender() {\n  return (\n    \u003cView style={styles.container}\u003e\n      \u003cStatusBarAlert\n        visible={this.state.alerts.length \u003e 0}\n        {...this.state.alerts[0]}\n      /\u003e\n      \u003cNavigator\n        initialRoute={initialRoute}\n        renderScene={this.renderScene}\n        navigationBar={\n          \u003cNavigator.NavigationBar\n            routeMapper={routeMapper}\n            style={{top: -20}}\n          /\u003e\n        }\n      /\u003e\n    \u003c/View\u003e\n  )\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnestor%2Freact-native-silent-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnestor%2Freact-native-silent-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnestor%2Freact-native-silent-switch/lists"}