{"id":17655726,"url":"https://github.com/mergesort/FeedbackEffect","last_synced_at":"2025-03-11T00:31:40.031Z","repository":{"id":56911175,"uuid":"99446335","full_name":"mergesort/FeedbackEffect","owner":"mergesort","description":"A library for playing sounds and providing haptic feedback with ease.","archived":false,"fork":false,"pushed_at":"2021-01-17T15:13:13.000Z","size":64,"stargazers_count":233,"open_issues_count":1,"forks_count":10,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-04T20:02:25.472Z","etag":null,"topics":["feedback","haptics","ios","sound","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/mergesort.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-05T20:31:56.000Z","updated_at":"2025-01-28T04:46:48.000Z","dependencies_parsed_at":"2022-08-20T20:20:42.624Z","dependency_job_id":null,"html_url":"https://github.com/mergesort/FeedbackEffect","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FFeedbackEffect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FFeedbackEffect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FFeedbackEffect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mergesort%2FFeedbackEffect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mergesort","download_url":"https://codeload.github.com/mergesort/FeedbackEffect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242950884,"owners_count":20211569,"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":["feedback","haptics","ios","sound","swift"],"created_at":"2024-10-23T13:01:41.600Z","updated_at":"2025-03-11T00:31:40.015Z","avatar_url":"https://github.com/mergesort.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# FeedbackEffect\n\n### A μ library for playing sound effects and providing haptic feedback… with ease.\n\n[![BuddyBuild](https://dashboard.buddybuild.com/api/statusImage?appID=59b1c96ebb97170001f8ebd4\u0026branch=master\u0026build=latest)](https://dashboard.buddybuild.com/apps/59b1c96ebb97170001f8ebd4/build/latest?branch=master)\n[![Pod Version](https://img.shields.io/badge/Pod-1.5.0-6193DF.svg)](https://cocoapods.org/)\n![Swift Version](https://img.shields.io/badge/Swift-%205.0-brightgreen.svg)\n![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg) \n![Plaform](https://img.shields.io/badge/Platform-iOS-lightgrey.svg)\n\n### Your app should be special. Other people's apps suck. How do we make your app extra awesome? Feedback and sound effects my friend.\n\nUntil now there has not been a unified API to allow you to integrate sound effects _and_ haptic feedback with ease. If you're guessing that now there is, then you're right… now there is.\n\n---\n\n### The API couldn't be simpler.\n\n```swift\nlet selectionFeedback = HapticFeedback.notification(.success)\nlet soundUrl = Bundle.main.url(forResource: \"Success\", withExtension: \"m4a\")\nFeedbackEffect.play(sound: soundUrl, feedback: selectionFeedback)\n```\n\n---\n\n### Q\u0026A time\n\n**Q: Is that all?**\n\nA: Yep.\n\n**Q: Really?**\n\nA: Fine, let's go into more detail.\n\n---\n\n### SoundEmitting\n\nThere are two kinds of `SoundEmitting`. You can provide a URL to any resource that iOS can play (such as an m4a), or use some common sounds from iOS pre-configured.\n\nThree types conform to `SoundEmitting` out of the box:\n\n- URL\n- MessageTone\n- SoundEffect\n\nIf you'd like to add some more, all you have to do is conform to the protocol. If you find some more that are built into iOS, feel free to file a PR and it'll gladly be accepted.\n\n---\n\n### HapticEmitting\n\nThere are two ways to provide a user with haptic feedback. Both `HapticFeedback` and `VibrationFeedback` conform to `HapticEmitting`.\n\n- **HapticFeedback**: Uses iOS's built in `UIFeedbackGenerator` to generate feedback effects. You can use this just how you would normally use `UIImpactGenerator`, `UISelectionGenerator`, and `UINotificationFeedbackGenerator`.\n\n- **VibrationFeedback**: For older devices which do not have a taptic engine. It will generate similar vibration patterns to the `UIFeedbackGenerator`, which unfortunately do not match `UIFeedbackGenerator` exactly one for one but are rather close.\n\n---\n\n### Q\u0026A part II\n\n**Q: Is that it?**\n\nA: Yep. You're on your own from here padawan. Let's leave you with a few more examples to make you feel safe though.\n\n---\n\n### Examples\n\nUses the haptic feedback built into iOS along with the tap sound to make a user feel like they're really tapping a button.\n\n```swift\nlet notificationFeedback = HapticFeedback.selection\nlet tapSound = SoundEffect.tap\nFeedbackEffect.play(sound: tapSound, feedback: notificationFeedback)\n```\n\nUses the haptic feedback built into iOS along with an success sound to make a user feel they've completed a unit of work successfully.\n\n```swift\nlet selectionFeedback = HapticFeedback.notification(.success)\nlet soundUrl = Bundle.main.url(forResource: \"Success\", withExtension: \"m4a\")\nFeedbackEffect.play(sound: soundUrl, feedback: selectionFeedback)\n```\n\nUses the vibration feedback fallback (for users without 3D Touch devices) built into iOS along with a pre-configured sound effect.\n\n```swift\nlet vibration = VibrationFeedback.notification\nlet sound = MessageTone.tweet\nFeedbackEffect.play(sound: sound, feedback: vibration)\n```\n\nYou can use just one at a time too if you wish. Just provide haptics and leave the sound parameter nil. You can also do the opposite and provide a sound with no haptics.\n\n```swift\nlet vibration = HapticFeedback.notification(.error)\nFeedbackEffect.play(sound: nil, feedback: vibration)\n```\n\n---\n\n## Requirements\n\n- iOS 10.0+\n- Xcode 8.0+\n\n## Installation\n\nSPM will be the default supported installation method from version 1.5.0 and higher, so please integrate by using SPM.\n\nIf you're still using [CocoaPods](http://cocoapods.org/) for version 1.5.0 or below you can install `FeedbackEffect` by adding it to your `Podfile`:\n\n```ruby\nplatform :ios, '10.0'\nuse_frameworks!\n\npod 'FeedbackEffect'\n```\n\nOr install it manually by downloading `FeedbackEffect.swift` and dropping it in your project.\n\n## About me\n\nHi, I'm [Joe](http://fabisevi.ch) everywhere on the web, but especially on [Twitter](https://twitter.com/mergesort).\n\n## License\n\nSee the [license](LICENSE) for more information about how you can use TypedNotifications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FFeedbackEffect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmergesort%2FFeedbackEffect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmergesort%2FFeedbackEffect/lists"}