{"id":21454847,"url":"https://github.com/hallee/simple-haptics","last_synced_at":"2025-10-18T09:13:37.229Z","repository":{"id":63911739,"uuid":"225216204","full_name":"hallee/simple-haptics","owner":"hallee","description":"👇 Core Haptics convenience wrapper for SwiftUI to make haptic taps simple","archived":false,"fork":false,"pushed_at":"2020-01-28T01:28:40.000Z","size":8,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-14T22:09:35.125Z","etag":null,"topics":["combine","corehaptics","haptic-feedback","haptics","swift","swiftui","uifeedbackgenerator","uikit"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/hallee.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":"2019-12-01T19:20:35.000Z","updated_at":"2024-01-14T12:59:12.000Z","dependencies_parsed_at":"2023-01-14T13:15:28.221Z","dependency_job_id":null,"html_url":"https://github.com/hallee/simple-haptics","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hallee%2Fsimple-haptics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hallee%2Fsimple-haptics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hallee%2Fsimple-haptics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hallee%2Fsimple-haptics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hallee","download_url":"https://codeload.github.com/hallee/simple-haptics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226003019,"owners_count":17558157,"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":["combine","corehaptics","haptic-feedback","haptics","swift","swiftui","uifeedbackgenerator","uikit"],"created_at":"2024-11-23T05:09:21.972Z","updated_at":"2025-10-18T09:13:32.198Z","avatar_url":"https://github.com/hallee.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Haptics\n\nSimple Haptics is a convenience wrapper for [`Core Haptics`](https://developer.apple.com/documentation/corehaptics) to make it easier to fire transient haptic taps, similar to `UIFeedbackGenerator`.\n\n## Usage\n\n```swift\nimport SimpleHaptics\n\nlet haptics = SimpleHapticGenerator()\n\ntry? haptics.fire(intensity: 0.5, sharpness: 1)\n```\n\n### Integration with SwiftUI\n\nSimple Haptics works well when integrated with `@Environment`. You can create a single `SimpleHapticGenerator` and pass it as an environment object to your root SwiftUI view, then use it in any child views that need haptic feedback. This prevents needing to initialize lots of `CHHapticEngine`s unecessarily, and allows you to stop and start the haptic engine on app lifecycle events. For example, in your `SceneDelegate`:\n\n```swift\nimport SimpleHaptics\nimport SwiftUI\n\nclass SceneDelegate: UIResponder, UIWindowSceneDelegate {\n\n    let haptics = SimpleHapticGenerator()\n\n    ...\n\n    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {\n\n        let contentView = ContentView()\n            .environmentObject(haptics) // Pass your haptic generator into your root View.\n\n    ...\n\n    // Be sure to stop the haptic generator when entering the background.\n    func sceneDidEnterBackground(_ scene: UIScene) {\n        haptics.stop()\n    }\n\n    func sceneWillEnterForeground(_ scene: UIScene) {\n        try? haptics.start()\n    }\n\n}\n```\n\nAnd then child views can use it simply by creating an `@EnvironmentObject` variable of the correct type:\n\n```swift\nimport SimpleHaptics\nimport SwiftUI\n\nstruct MyView: View {\n\n    @EnvironmentObject private var haptics: SimpleHapticGenerator\n\n    ...\n\n}\n```\n\n\n\n## Installation\n\n#### SwiftPM\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/hallee/simple-haptics\", from: \"0.0.2\")\n],\ntargets: [\n    .target(name: \"YourTarget\", dependencies: [\"SimpleHaptics\"])\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhallee%2Fsimple-haptics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhallee%2Fsimple-haptics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhallee%2Fsimple-haptics/lists"}