Haptico 📳 - easy to use haptic feedback generator with pattern-play support

Overview

Haptico

Haptico is easy to use iOS haptic feedback generator. Besides default haptic feedbacks it can play patterns! Checkout Example project.

CI Status Version License Platform

Table of contents

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

How to use

First of all you will need to import Haptico module into your class:

import Haptico

Also keep in mind that depending on the device you are using - the feedback might be different. Starting from iPhone 7 all the iPhones are coming with haptic engine. Prior to iPhone 7 Haptico will use standard vibration. Also Pattern play and impacts are not supported on devices prior to iPhone 7 and iOS 10

1. Generating predefined default feedbacks.

With Haptico you can generate three default types of haptic notifications:

public enum HapticoNotification {
    case success
    case warning
    case error
}

Here is small example how can you generate Success, Warning and Error feedbacks:

@IBAction func generateSuccess(_ sender: Any) {
    Haptico.shared().generate(.success)
}
@IBAction func generateWarning(_ sender: Any) {
    Haptico.shared().generate(.warning)
}
@IBAction func generateError(_ sender: Any) {
    Haptico.shared().generate(.error)
}

2. Generating impact feedbacks

Besides default haptic notifications, Haptico can also generate impact notifications. The library supports three types of impact notifications (available in iOS10+ and staring from iPhone 7):

public enum HapticoImpact {
    case light
    case medium
    case heavy
}

And to use them call:

Haptico.shared().generate(.medium)

Easy, huh?

3. Pattern play

And now something special - Pattern Play. Haptico can play patterns, "coded" as String. Let's take a look at small example:

Haptico.shared().generateFeedbackFromPattern("..oO-Oo..", delay: 0.1)

Each character in this string represents some specific haptic impact:

  • "O" (capital "o") - heavy impact
  • "o" - medium impact
  • "." - light impact
  • "-" - delay which has duration of 0.1 second

4. UI extensions

Haptico comes with a couple of UI Extensions: HapticoButton (which is subclass of UIButton) and UIAlertController extension with haptic feedback.

In order to start using HapticoButton - just set the class name in your Storyboard to HapticoButton. Then with UIControlEvents.touchDown event you will get heavy impact feedback and with UIControlEvents.touchUpInside and UIControlEvents.touchUpOutside you will get light impact feedback.

To use Haptico together with UIAlertController follow this simple example:

func showSuccessAlert() {
    let alert = UIAlertController(title: "Alert Title", message: "Alert Message", preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
    present(alert, animated: true, hapticNotification: .success)
}

Installation

Haptico is available through CocoaPods, Carthage and Swift Package Manager.

Cocoapods

To install it using CocoaPods, simply add the following line to your Podfile:

pod 'Haptico'

Carthage

To install it via Carthage, add the following line to your Cartfile and follow the instructions to adding frameworks to an application:

github "iSapozhnik/Haptico"

Swift Package Manager

To install it using the Swift Package Manager, either directly add it to your project using Xcode 11, or specify it as dependency in the Package.swift file:

// ...
dependencies: [
    .package(url: "https://github.com/iSapozhnik/Haptico.git", from: "1.1.0"),
],
//...

Mentions

Author

isapozhnik, [email protected]

Donation

If you like this project and it helps you to reduce time to develop, you can give me a cup of ☕️ 😉

Donate

License

Haptico is available under the MIT license. See the LICENSE file for more info.

Comments
  • Add capability for new devices

    Add capability for new devices

    Set hasHapticFeedback to use CoreHaptics to detect if device has haptic engine if device is using iOS 13+ instead of having to rely on a device list that has to be updated each time new iPhones are released.

    opened by justinkumpe 7
  • iPhone 11 above doesn't support hapticFeedback

    iPhone 11 above doesn't support hapticFeedback

    Maybe it's because on UIDevice+Extensions it only checks up to iPhone XS Max.

            get {
                return deviceType == .iPhone6S || deviceType == .iPhone6SPlus ||
                    deviceType == .iPhone7 || deviceType == .iPhone7Plus ||
                    deviceType == .iPhone8 || deviceType == .iPhone8Plus ||
                    deviceType == .iPhoneX || deviceType == .iPhoneXR ||
                    deviceType == .iPhoneXS || deviceType == .iPhoneXSMax
    
            }```
    
    I said maybe because I don't have iPhone 11 device so I'm not sure if adding iPhone 11 checking will solve the problem.
    opened by thidayatullah 2
  • Added iPhone12 Models

    Added iPhone12 Models

    Added iPhone12 models to UIDevice+Extensions.swift.

    Also bumped version number in podsec file. If merged please push new version to cocoapods. Pushing new version will also resolve #14

    opened by justinkumpe 1
  • Add support for Swift Package Manager

    Add support for Swift Package Manager

    Description

    As follow-up to #8, this PR adds support for Swift Package Manager. Since I had to fix some of the imports I also raised the version to 1.1.0.

    opened by ffittschen 1
  • Add Carthage support

    Add Carthage support

    Description

    This PR adds Carthage support to Haptico. To do so, I had to delete the top level symlink _Pods.xcodeproj -> Example/Pods/Pods.xcodeproj since it was confusing carthage.

    enhancement 
    opened by ffittschen 1
Releases(1.0.2)
Owner
Sapozhnik Ivan
iOS and macOS
Sapozhnik Ivan
TapticEngine generates haptic feedback vibrations on iOS device.

TapticEngine Overview TapticEngine generates haptic feedback vibrations on iOS device. This library wrapps on UIImpactFeedbackGenerator, UISelectionFe

WorldDownTown 253 Oct 28, 2022
🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring

Location Manager Made Easy SwiftLocation is a lightweight Swift Library that provides an easy way to work with location-related functionalities. No mo

Daniele Margutti 3.2k Dec 30, 2022
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, in

EFPrefix 4.3k Jan 2, 2023
Library for iOS Camera API. Massively increase performance and ease of use within your next iOS Project.

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service that scales,

CameraKit 628 Dec 27, 2022
Just simple template - example how to use haptics in iOS Development

Haptics Just simple template - example how to use haptics in iOS Development imp

Alexander Ryakhin 1 Jan 31, 2022
WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS.

WatchCon WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS Requirements iOS 9.0+ / watchOS 2.0+ CocoaPods CocoaPods

Abdullah Selek 33 Sep 22, 2022
Easy Haptic Feedback Generator 📳

Haptica is an easy haptic feedback generator. $ pod try Haptica Requirements iOS 9.0+ Xcode 8.0+ Swift 5 (Haptica 3.x), Swift 4 (Haptica 2.x), Swift

Lasha Efremidze 702 Jan 1, 2023
Easy Haptic Feedback Generator 📳

Haptica is an easy haptic feedback generator. $ pod try Haptica Requirements iOS 9.0+ Xcode 8.0+ Swift 5 (Haptica 3.x), Swift 4 (Haptica 2.x), Swift

Lasha Efremidze 702 Jan 1, 2023
🔥 🔥 🔥Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

?? ?? ??Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

null 60 Dec 12, 2022
TapticEngine generates haptic feedback vibrations on iOS device.

TapticEngine Overview TapticEngine generates haptic feedback vibrations on iOS device. This library wrapps on UIImpactFeedbackGenerator, UISelectionFe

WorldDownTown 253 Oct 28, 2022
✨ Super easy Parallax and Haptic Effect.

IParallaxAndHapticEffect ✨ Super easy Parallax and Haptic Effect. This library helps you easily use the 'Parallax' and 'Haptic' effects. Customized 3D

Hae Chan 2 Feb 9, 2022
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

Ivan Vorobei 1.4k Dec 10, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
Mahmoud-Abdelwahab 5 Nov 23, 2022
TopicEventBus is Easy to use, type safe way of implementing Publish–subscribe design pattern.

TopicEventBus Publish–subscribe design pattern implementation framework, with ability to publish events by topic. (NotificationCenter extended alterna

Matan Abravanel 55 Nov 29, 2021
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
PinpointKit is an open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots using a simple gesture.

PinpointKit is an open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots using a simple gesture. F

Lickability 1.1k Jan 6, 2023
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

SPAlert Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Supports Dark Mode. I tried to recreate Apple's

Ivan Vorobei 1.8k Jan 7, 2023
Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event.

Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event. Goals of this project One of th

Zigii Wong 410 Sep 9, 2022