function createHandler(name) {
	return function (body) {
		if (!window.webkit) {
			return
		}

		if (!(name in window.webkit.messageHandlers)) {
			return
		}

		try {
			window.webkit.messageHandlers[name].postMessage(body)
		} catch (error) {
			console.error(error)
		}
	}
}

function providesHandler(name) {
	if (!window.webkit) {
		return false
	}

	return name in window.webkit.messageHandlers
}

export default {
	providesHandler: providesHandler,

	onLogout: createHandler('onLogout'),
	setApiKey: createHandler('setApiKey'),
	setBackgroundColor: createHandler('setBackgroundColor'),
	setBackgroundTintColor: createHandler('setBackgroundTintColor'),
	showManageSubscriptions: createHandler('showManageSubscriptions')

	// Haptic Feedback
	onSelectionFeedback: createHandler('onSelectionFeedback'),
	onRigidImpactFeedback: createHandler('onRigidImpactFeedback'),
	onSoftImpactFeedback: createHandler('onSoftImpactFeedback'),
	onLightImpactFeedback: createHandler('onLightImpactFeedback'),
	onMediumImpactFeedback: createHandler('onMediumImpactFeedback'),
	onHeavyImpactFeedback: createHandler('onHeavyImpactFeedback'),
	onSuccessFeedback: createHandler('onSuccessFeedback'),
	onWarningFeedback: createHandler('onWarningFeedback'),
	onErrorFeedback: createHandler('onErrorFeedback'),
}

You can use ‘Haptic Haven’ to test different kinds of haptic feedback:

‎Haptic Haven

some Qs from

Playing haptics | Apple Developer Documentation

> Make haptics optional. Let people turn off or mute haptics if they wish, and make sure people can still enjoy your app without them.

is there a native convention for settings this? like a Kinopio entry in settings.app that will expose keys/values for the native app to pass to the website?

alternatively I can expose a setting for this in the normal kinopio settings when window.webkit is detected