benjamindean/flutter_vibration

Vibrate fails on iOS using custom pattern

Opened this issue · 16 comments

iOS 16.1.2
iPhone 11

I currently run the following code:

Vibration.vibrate(pattern: [500, 500, 500, 500]);
[hapi]  CHHapticPatternPlayer.mm:132   -[PatternPlayer initWithPlayable:engine:privileged:error:]: ERROR: pattern contains no playable events
Failed to play pattern: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.).

Both Vibration.hasVibrator() and Vibration.hasCustomVibrationsSupport() return true. So this appears like it should work, but instead error is being thrown.

I have the same problem, too.

Iphone SE(2020)
iOS 13.4.1

Same problem on iOS 16.2 and v1.7.6

n04h commented

I also have the same problem.

iPhone 11 Pro
iOS 16.2

Ok, looking at code in https://github.com/benjamindean/flutter_vibration/blob/master/vibration/ios/Classes/VibrationPluginSwift.swift#L81 it looks like you NEED to pass intensities, there is no any default values for them -_-

It was broken in #51

@Amareis that fixed the issue. If someone wants to take a stab at the PR for a default value that would fix iOS.

Yes, and also simple vibrate(duration: duration) can be emulated via vibrate(pattern: [0, duration], intensities: [0, 255]). I think it should be handled in swift plugin directly, instead of fallback to dumb long standart vibration.

Vibration.vibrate(
pattern: [500, 1000, 500, 2000, 500, 3000, 500, 500],
repeat: 1,
intensities: [0, 128, 0, 255, 0, 64, 0, 255],
);
This code is not working in iOS devices.

Vibration.vibrate( pattern: [500, 1000, 500, 2000, 500, 3000, 500, 500], repeat: 1, intensities: [0, 128, 0, 255, 0, 64, 0, 255], ); This code is not working in iOS devices.

Its not working on mine too..

Try it without repeat

Try it without repeat
Nope it would help by removing repeat: 1,
so how to make iOS device keep vibrating continuously?

@Amareis i am getting same error

[hapi]  CHHapticPatternPlayer.mm:132   -[PatternPlayer initWithPlayable:engine:privileged:error:]: ERROR: pattern contains no playable events
Failed to play pattern: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.).

any update?

@flyingcircle how did you manage to fix the issue?

Hey! Sorry for the late reply, but I will soon get an actual iPhone to debug it on so I'll look into it. Thank you for your patience!

Is there any progress?