-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the maximum duration time of vibration in ios #98
Comments
I have the same issue, is there any limitation, or property that needs to be set? |
A bit of a hack, but I had a similar issue and switched the trigger method to |
I resolved this with the following patch, hope it's of any use. react-native-haptic-feedback+2.2.0.patch diff --git a/node_modules/react-native-haptic-feedback/ios/RNHapticFeedback/RNHapticFeedback.mm b/node_modules/react-native-haptic-feedback/ios/RNHapticFeedback/RNHapticFeedback.mm
index cf75baf..1ca2da3 100644
--- a/node_modules/react-native-haptic-feedback/ios/RNHapticFeedback/RNHapticFeedback.mm
+++ b/node_modules/react-native-haptic-feedback/ios/RNHapticFeedback/RNHapticFeedback.mm
@@ -100,11 +100,10 @@ RCT_EXPORT_METHOD(trigger:(NSString *)type options:(NSDictionary *)options)
impactGeneratorMap = [[NSMutableDictionary alloc] init];
if ([impactGeneratorMap objectForKey:key] == nil){
[impactGeneratorMap setValue:[[UIImpactFeedbackGenerator alloc] initWithStyle:style] forKey:key];
- [[impactGeneratorMap objectForKey:key] prepare];
}
- UIImpactFeedbackGenerator *generator = [impactGeneratorMap objectForKey:key];
- [generator impactOccurred];
- [generator prepare];
+ [[impactGeneratorMap objectForKey:key] prepare];
+ [[impactGeneratorMap objectForKey:key] performSelector:@selector(impactOccurred) withObject: nil afterDelay:0.0f];
+ [[impactGeneratorMap objectForKey:key] prepare];
}
-(void)generateNotificationFeedback:(UINotificationFeedbackType)notificationType{
|
Is this related to a limitation of iOS regarding the haptics? Would be glad to have a reference, but couldn´t find anything. The diff is only triggering the prepare again, or am i missing something @jpitkanen17 |
@mkuczera The extra prepare call might be redundant and something I tried before figuring the real solution out. The actual solution is this call The key difference is the delay 0.0f which overrides the previous haptics call. I tested this with a slider that would stop vibrating on every click after a while and this fixed it. The only "bug" is that sometimes the you can feel the vibration being cancelled. |
Description
I am making an exercise app, and I have the haptic activated when the round starts, the problem is that a round lasts 50 seconds, if it passes 25 seconds it stops vibrating, this only happens on iOS, I would like to know if there is a restriction in the library about the maximum haptic time, this problem in android does not happen.
My example code
Package version
"react": "17.0.2",
"react-native": "0.66.5",
"react-native-haptic-feedback": "^2.0.0",
Example visual
The text was updated successfully, but these errors were encountered: