Core Haptics Implementation for iOS App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Core Haptics Implementation for iOS App
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Core Haptics for iOS App

Core Haptics appeared in iOS 13 and works on iPhone 8 and newer. Unlike UIImpactFeedbackGenerator (canned system patterns), Core Haptics allows creating arbitrary tactile sensations: rise shape, duration, combination of vibration and audio tone through one engine — CHHapticEngine.

How CHHapticEngine Works

The engine works with events of two types: CHHapticEvent.EventType.hapticTransient (short "click", like button press) and CHHapticEvent.EventType.hapticContinuous (sustained vibration). Each event has parameters attached: intensity (hapticIntensity), sharpness (hapticSharpness).

import CoreHaptics

class HapticsManager {
    private var engine: CHHapticEngine?

    func prepareEngine() {
        guard CHHapticEngine.capabilitiesForHardware().supportsHaptics else { return }

        do {
            engine = try CHHapticEngine()
            engine?.playsHapticsOnly = true
            try engine?.start()
        } catch {
            print("CoreHaptics engine error: \(error)")
        }

        // Recovery after interruption (call, another app)
        engine?.resetHandler = { [weak self] in
            try? self?.engine?.start()
        }
        engine?.stoppedHandler = { reason in
            print("Haptic engine stopped: \(reason)")
        }
    }
}

playsHapticsOnly = true — if synchronized audio tone is not needed. Without this flag, CHHapticEngine also manages audio through CoreAudio, which requires audio session setup.

Creating Patterns

Complex pattern is an array of CHHapticEvent with time stamps:

func playSuccessPattern() throws {
    guard let engine = engine else { return }

    let events: [CHHapticEvent] = [
        // Quick click
        CHHapticEvent(
            eventType: .hapticTransient,
            parameters: [
                CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.5),
                CHHapticEventParameter(parameterID: .hapticSharpness, value: 0.8)
            ],
            relativeTime: 0
        ),
        // Rising vibration
        CHHapticEvent(
            eventType: .hapticContinuous,
            parameters: [
                CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0),
                CHHapticEventParameter(parameterID: .hapticSharpness, value: 0.3)
            ],
            relativeTime: 0.1,
            duration: 0.4
        ),
        // Final click
        CHHapticEvent(
            eventType: .hapticTransient,
            parameters: [
                CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.8),
                CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
            ],
            relativeTime: 0.55
        )
    ]

    let pattern = try CHHapticPattern(events: events, parameters: [])
    let player = try engine.makePlayer(with: pattern)
    try player.start(atTime: CHHapticTimeImmediate)
}

hapticSharpness — subjective "sharpness" of vibration: 1.0 is sharp click-like impulse, 0.0 is soft deep buzz. Combining these two parameters over time gives the "character" of the sensation.

Dynamic Parameter Modification

CHHapticDynamicParameter allows changing pattern in real-time — for example, increase vibration as slider is pressed:

func updateIntensity(_ value: Float) {
    let dynamicParam = CHHapticDynamicParameter(
        parameterID: .hapticIntensityControl,
        value: value,
        relativeTime: 0
    )
    try? continuousPlayer?.sendParameters([dynamicParam], atTime: 0)
}

This is key feature for games and interactive interfaces: feedback changes in sync with user action.

AHAP Files

Apple Haptic and Audio Pattern (.ahap) — JSON format for describing patterns:

{
    "Version": 1.0,
    "Pattern": [
        {
            "Event": {
                "Time": 0.0,
                "Type": "HapticTransient",
                "Parameters": [
                    { "ParameterID": "HapticIntensity", "ParameterValue": 1.0 },
                    { "ParameterID": "HapticSharpness", "ParameterValue": 0.5 }
                ]
            }
        }
    ]
}

Load from file: engine?.playPattern(from: url). Designer can edit .ahap without code changes. Xcode has built-in Core Haptics Composer for visual pattern creation.

Typical Issues

Engine stops when app transitions to backgroundCHHapticEngine.stoppedHandler is called with .applicationSuspended. On return to foreground, you need to recreate or restart engine. resetHandler must be set before startup.

Simulator doesn't support Core Haptics — test only on real iPhone 8+ device. CHHapticEngine.capabilitiesForHardware().supportsHaptics returns false on simulator and iPad.

Delay on first startCHHapticEngine initialization takes ~50–100 ms. Call prepareEngine() beforehand, not at event time.

Timeline Benchmarks

Basic patterns (2–3 types) with correct engine initialization and interrupt handling — 1 day. Dynamic patterns with real-time parameter changes, AHAP files, game event integration — 2–3 days.