Skip to content

Support vibrate(intensity, mode) for iOS #1904

@ParticleG

Description

@ParticleG

On iOS 10.0+, iPadOS 10.0+ and Mac Catalyst 13.1+, it is possible for iPhones and iPads to generate different type of viberations, Not just a fixed 400ms one. Just Mapping seconds to UIFeedbackGenerator's subclasses like this:

if (@available(iOS 10.0, *)) {
	// iOS 10.0 and above
	UIImpactFeedbackGenerator *impact = nil;
	if (seconds >= 0.5 && seconds < 1.5) {
		impact = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
	} else if (seconds >= 1.5 && seconds < 2.5) {
		impact = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium];
	} else if (seconds >= 2.5) {
		impact = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy];
	} else {
		return;
	}
	[impact impactOccurred];
	return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestiOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions