benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
217 stars 67 forks source link

Vibrate fails on iOS using custom pattern #79

Open flyingcircle opened 1 year ago

flyingcircle commented 1 year ago

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.

oorfalimak commented 1 year ago

I have the same problem, too.

Iphone SE(2020) iOS 13.4.1

NicklasFrederiksen commented 1 year ago

Same problem on iOS 16.2 and v1.7.6

n04h commented 1 year ago

I also have the same problem.

iPhone 11 Pro iOS 16.2

Amareis commented 1 year ago

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 -_-

Amareis commented 1 year ago

It was broken in https://github.com/benjamindean/flutter_vibration/pull/51

flyingcircle commented 1 year ago

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

Amareis commented 1 year ago

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.

pranavo72bex commented 1 year ago

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.

bibek-magar commented 1 year ago

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..

Amareis commented 1 year ago

Try it without repeat

pranavo72bex commented 1 year ago

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

pranavo72bex commented 1 year ago

@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.).
pranavo72bex commented 1 year ago

any update?

pranavo72bex commented 1 year ago

@flyingcircle how did you manage to fix the issue?

benjamindean commented 1 year ago

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!

luomo-pro commented 7 months ago

Is there any progress?