mkuczera / react-native-haptic-feedback Goto Github PK
View Code? Open in Web Editor NEWReact-Native Haptic Feedback for iOS with Android similar behaviour.
License: MIT License
React-Native Haptic Feedback for iOS with Android similar behaviour.
License: MIT License
I've read that v2.0 supports the React Native Fabric ("new arch"). I'm on v2.0.2 but if I pod install with RCT_NEW_ARCH_ENABLED=1 pod install
codegen runs successfully on all the other pods but on react-native-haptic-feedback it fails with:
Here is the error:
Error: ENOENT: no such file or directory, lstat '/path/to/my/project/node_modules/react-native-haptic-feedback/src'
at Object.lstatSync (node:fs:1561:3)
at /path/to/my/project/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:26:10
at Array.forEach (<anonymous>)
at Object.<anonymous> (/path/to/my/project/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:25:10)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
errno: -2,
syscall: 'lstat',
code: 'ENOENT',
path: '/path/to/my/project/node_modules/react-native-haptic-feedback/src'
}
Error: Command failed: node /path/to/my/project/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js --platform ios /var/folders/_m/n09zdv0j27nc57hp777p49xr0000gn/T/RNHapticFeedbackSpecKdJ631/schema.json /path/to/my/project/node_modules/react-native-haptic-feedback/src
/path/to/my/project/node_modules/flow-parser/flow_parser.js:807
throw a}function
^
Error: ENOENT: no such file or directory, lstat '/path/to/my/project/node_modules/react-native-haptic-feedback/src'
at Object.lstatSync (node:fs:1561:3)
at /path/to/my/project/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:26:10
at Array.forEach (<anonymous>)
at Object.<anonymous> (/path/to/my/project/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:25:10)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
errno: -2,
syscall: 'lstat',
code: 'ENOENT',
path: '/path/to/my/project/node_modules/react-native-haptic-feedback/src'
}
at checkExecSyncError (node:child_process:861:11)
at execSync (node:child_process:932:15)
at executeNodeScript (/path/to/my/project/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:38:3)
at generateSchema (/path/to/my/project/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:314:3)
at /path/to/my/project/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:373:26
at Array.forEach (<anonymous>)
at generateNativeCodegenFiles (/path/to/my/project/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:362:13)
at Object.execute (/path/to/my/project/node_modules/react-native/scripts/codegen/generate-artifacts-executor.js:532:5)
at Object.<anonymous> (/path/to/my/project/node_modules/react-native/scripts/generate-codegen-artifacts.js:64:10) {
status: 7,
signal: null,
output: [
null,
<Buffer >,
<Buffer 2f 55 73 65 72 73 2f 43 61 6e 2f 44 6f 63 75 6d 65 6e 74 73 2f 50 72 6f 67 72 61 6d 6d 69 6e 67 2f 52 65 61 63 74 2f 44 61 56 69 6e 63 69 2f 6e 6f 64 ... 1152 more bytes>
],
pid: 20816,
stdout: <Buffer >,
stderr: <Buffer 2f 55 73 65 72 73 2f 43 61 6e 2f 44 6f 63 75 6d 65 6e 74 73 2f 50 72 6f 67 72 61 6d 6d 69 6e 67 2f 52 65 61 63 74 2f 44 61 56 69 6e 63 69 2f 6e 6f 64 ... 1152 more bytes>
}
.
# from /path/to/my/project/ios/Podfile:35
# -------------------------------------------
#
> use_react_native!(
# :path => config[:reactNativePath],
# -------------------------------------------
[!] [Codegen] warn: using experimental new codegen integration
I've tried deleting Pods
directory, Podfile.lock
, and ios's build
directory but no avail, still the same error.
when setting enableVibrateFallback true on IPHONE 6s is not playing the default or any kind of vibration, is it supposed to be working ?
I checked the similar issues, but wasn't been able to resolved it mine.
Had a RNReactNativeHapticFeedback is not available warning, and no feedback when I clicked on the button. Running on the latest iOS version (13.4), Expo version 2.15.2, and react-native 0.62.
here is my log in my console.
RNReactNativeHapticFeedback is not available
- node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
- node_modules/react-native-haptic-feedback/index.js:14:22 in RNReactNativeHapticFeedback.trigger
* components/Twitter/TwitterHeart.js:13:24 in onPress
- node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js:336:45 in createReactClass$argument_0.touchableHandlePress
* [native code]:null in touchableHandlePress
- node_modules/react-native/Libraries/Components/Touchable/Touchable.js:880:34 in TouchableMixin._performSideEffectsForTransition
* [native code]:null in _performSideEffectsForTransition
- node_modules/react-native/Libraries/Components/Touchable/Touchable.js:779:44 in TouchableMixin._receiveSignal
* [native code]:null in _receiveSignal
- node_modules/react-native/Libraries/Components/Touchable/Touchable.js:490:24 in TouchableMixin.touchableHandleResponderRelease
* [native code]:null in touchableHandleResponderRelease
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:555:30 in invokeGuardedCallbackAndCatchFirstError
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:722:42 in executeDispatch
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:744:20 in executeDispatchesInOrder
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:907:29 in executeDispatchesAndRelease
* [native code]:null in forEach
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:887:16 in forEachAccumulated
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:932:21 in runEventsInBatch
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:1096:19 in runExtractedPluginEventsInBatch
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2796:6 in batchedUpdates$argument_0
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18791:14 in batchedUpdates$1
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2709:30 in batchedUpdates
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2794:17 in batchedUpdates$argument_0
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2870:28 in receiveTouches
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/Messa
Not have any clue in what to do.
Thx very much for your potential help :)
Right now we can use enableVibrateFallback
to enable old iPhones to vibrate (because there's no haptic feedback available). However, based on docs, the default vibration is 1 second.
However, based on React Native official docs, on iOS, the vibration duration is fixed at roughly 400 milliseconds.
Why are we using a different default vibration using this library? Also, is it possible to reduce to the minimum (let's say, those 400ms)?
Thank you guys ๐
I think there might be an issue with the typings introduced in #78
TypeScript complains to me about line 35 of index.d.ts
that "An export assignment cannot be used in a module with other exported elements"
It looks like the selection
method is not working on Android.
Android: 11
react-native-haptic-feedback: 1.13.0
Issue:
pod install fails due to missing package declaration in .podspec
Fix:
https://github.com/milk-and-cookies-io/react-native-haptic-feedback/pull/36/files
it doesn't work on newest iPhone with iOS above 16.0.0
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-haptic-feedback/android/src/main/java/com/mkuczera/RNReactNativeHapticFeedbackPackage.java b/node_modules/react-native-haptic-feedback/android/src/main/java/com/mkuczera/RNReactNativeHapticFeedbackPackage.java
index 945ff34..13cc1cb 100644
--- a/node_modules/react-native-haptic-feedback/android/src/main/java/com/mkuczera/RNReactNativeHapticFeedbackPackage.java
+++ b/node_modules/react-native-haptic-feedback/android/src/main/java/com/mkuczera/RNReactNativeHapticFeedbackPackage.java
@@ -1,4 +1,3 @@
-
package com.mkuczera;
import androidx.annotation.Nullable;
@@ -26,21 +25,24 @@ public class RNReactNativeHapticFeedbackPackage extends TurboReactPackage {
@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
- return () -> {
- final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
- boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
- moduleInfos.put(
- RNReactNativeHapticFeedbackModuleImpl.NAME,
- new ReactModuleInfo(
- RNReactNativeHapticFeedbackModuleImpl.NAME,
- RNReactNativeHapticFeedbackModuleImpl.NAME,
- false, // canOverrideExistingModule
- false, // needsEagerInit
- true, // hasConstants
- false, // isCxxModule
- isTurboModule // isTurboModule
- ));
- return moduleInfos;
+ return new ReactModuleInfoProvider() {
+ @Override
+ public Map<String, ReactModuleInfo> getReactModuleInfos() {
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
+ moduleInfos.put(
+ RNReactNativeHapticFeedbackModuleImpl.NAME,
+ new ReactModuleInfo(
+ RNReactNativeHapticFeedbackModuleImpl.NAME,
+ RNReactNativeHapticFeedbackModuleImpl.NAME,
+ false, // canOverrideExistingModule
+ false, // needsEagerInit
+ true, // hasConstants
+ false, // isCxxModule
+ isTurboModule // isTurboModule
+ ));
+ return moduleInfos;
+ }
};
}
}
This issue body was partially generated by patch-package.
Hello,
Is there any solution to use haptic feedback when mic is active on iOs ?
React-Native: 0.63.4
expo: 42.0.1
`const options = {
enableVibrateFallback: true,
ignoreAndroidSystemSettings: false,
};
ReactNativeHapticFeedback.trigger("selection", options);
`
Thanks,
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
const options = {
enableVibrateFallback: false,
ignoreAndroidSystemSettings: true
};const interval = useRef(null);
const hapticLight = () => {
trigger("impactLight", options)
}useEffect(() => {
interval.current = setInterval(() => {
hapticLight()
}, 100);
return () => clearInterval(interval.current);
}, []);
Package version
"react": "17.0.2",
"react-native": "0.66.5",
"react-native-haptic-feedback": "^2.0.0",
I follow the guide for installation and the code snippet.
I get the error warning as below even I have try with different method:
WARN RNReactNativeHapticFeedback is not available
const options = {
enableVibrateFallback: true,
ignoreAndroidSystemSettings: false,
};
ReactNativeHapticFeedback.trigger('selection', options); // selection | impactLight and etc.....
I wanted to see what the difference is in this library vs. React Native's Vibration API. Thanks!
Hi!
I tested the package and only 'selection' and 'impactMedium' have any effect whatsoever.
Is this because the phone does not support lighter vibrations?
Thank you very much in advance!
Didn't used to be a problem on 1.1.0
, on 1.1.5
, 1.1.6
, & 1.1.7
I'm getting this error.. I haven't tried downgrading even further but reverting back to 1.1.0
always seems to work.
Anyone knows what's up?
OS: macOS
Deployment target: iPhone 6
RN: 0.55.4
React: 16.4.0
error: Invalid Zip archive: Could not find central directory end
** BUILD FAILED **
The following commands produced analyzer issues:
Analyze RNFIRMessaging.m normal arm64
(1 command with analyzer issues)
The following build commands failed:
PhaseScriptExecution Upload\ Debug\ Symbols\ to\ Sentry build/Build/Intermediates.noindex/Delta.build/Debug-iphoneos/Delta.build/Script-E2F64182CC5748C3B120353C.sh
(1 failure)
The Taptic Engine is supported from iPhone 6S. The iPhone SE for example supports the latest iOS, but doesn't support haptic feedback. If I trigger a feedback nothing happens.
I see two alternatives that'd improve this library:
Trigger a default vibration if the taptic engine isn't present.
Expose a function that tells if the taptic engine is available (the current function only checks for iOS >= 10.0). If not present the developer may decide to fallback to a default vibration.
Hey @mkuczera, I've just installed "react-native-haptic-feedback": "2.1.0"
in a "react-native": "^0.72.3"
project.
But running an android build - ./gradlew assembleDebug
, results in this error below in the class RNReactNativeHapticFeedbackPackage on this line in the getReactModuleInfoProvider function.
I notice one difference in your package source as it uses gradle-7.0.2-bin
whereas my project uses gradle-8.0.1-all
.
But I couldn't downgrade to 7.0.2
since my project relies on newer gradle configuration.
It seems like the compiler doesn't recognise the Map - cannot find the symbol "Map" in the context of the code
Can you help in any way to resolve this build issue?
Or if version 2.1.0 is compatible with [email protected]?
Error log out from ./gradlew assembleDebug
command:
> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Android gradle plugin: 7.4.2
Gradle: 8.0.1
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
> Task :react-native-haptic-feedback:compileDebugJavaWithJavac FAILED
/Users/brianvarley/Projects/react-native-prototyping/node_modules/react-native-haptic-feedback/android/src/main/java/com/mkuczera/RNReactNativeHapticFeedbackPackage.java:29: error: cannot find symbol
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
^
symbol: class Map
location: class RNReactNativeHapticFeedbackPackage
I've added some details about my package.json dependencies, node and java versions below:
"dependencies": {
"@mgcrea/react-native-dnd": "^1.4.0",
"bluebird": "^3.7.2",
"convert-units": "^2.3.4",
"event-emitter": "^0.3.5",
"fbjs": "^3.0.5",
"npm": "^9.8.1",
"prop-types": "^15.8.1",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.72.3",
"react-native-cli": "^2.0.1",
"react-native-config": "^1.5.1",
"react-native-gesture-handler": "2.9.0",
"react-native-haptic-feedback": "2.1.0",
"react-native-svg": "^13.10.0",
},
device : Galaxy S7 edge
android version : 8.0.0
react-native version : 0.68.1
react-native-haptic-feedback version : ^1.13.1
build.gradle info
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
When calling 'ReactNativeHapticFeedback.trigger' in Android version 8, an error like the one below occurs.
How can I avoid that error?
I tested the different settings on iOS and only these work for me (iPhone6S iOS 12.1.4):
All settings work on Android
Testing with:
const a = ['selection', 'impactLight', 'impactMedium', 'impactHeavy', 'notificationSuccess', 'notificationWarning', 'notificationError']
const rnd_vibration = a[Math.floor(Math.random()*6)]
console.log('vibrate: ', rnd_vibration)
ReactNativeHapticFeedback.trigger(rnd_vibration, true)
The ReactNativeHapticFeedback.trigger()
only activates if outside a function (based on limited testing). I want it to activate on button press.
For example, this works:
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
const MyScreen = () => {
ReactNativeHapticFeedback.trigger("selection");
}
...but these don't:
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
import { ConfirmDialog } from 'react-native-simple-dialogs';
import { Button } from 'react-native-elements';
const MyScreen = () => {
const handleButtonPress = () => {
ReactNativeHapticFeedback.trigger("selection");
}
<ConfirmDialog
...
positiveButton={{
title: "Button 1",
onPress: handleButtonPress
}}
/>
<Button
...
title="Button 2"
onPress={() => handleButtonPress()}
/>
<Button
...
title="Button 3"
onPress={ReactNativeHapticFeedback.trigger("selection")}
/>
}
Using options such as below does not help:
const options = {
enableVibrateFallback: true,
ignoreAndroidSystemSettings: false
};
Using different methods other than "selection"
don't help either.
At one point I glanced at my Xcode logs and surprisingly saw some non-React-Native logs, 3 or 4 of which were related to the haptics engine not starting. One of them said react-native-haptic-feedback failed to prewarm core haptics engine
. Google shows absolutely 0 results for this error.
Off to ugly old React Native Vibrate I guess...
UPDATE: The exact same bug occurs with Vibration.vibrate()
too! ๐ตโ๐ซ It works fine outside of an onPress
event, but as soon as it's implemented into an onPress
, it does nothing. This issue is documented by others here. I think this issue is rooted in a React Native bug, potentially conflicting with libraries or environment setup...
iOS 14.8 | React Native 0.64.2
Cross-reference to react-native
Vibration.vibrate()
issue: facebook/react-native#23404 (comment)
UPDATE 2: Just created a brand new React Native project on the latest React Native (0.66.0). With the below code, onPress={ReactNativeHapticFeedback.trigger("selection")}
activates when I open the app, but not when I press the button! ๐คฏ Same exact behavior with Vibration.vibrate()
(except it vibrates when the app is launched instead of doing the haptic feedback of course), so I think it's a React Native issue, rather than this library's.
import React, { useEffect } from 'react';
import {
View,
Button,
} from 'react-native';
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
const App = () => {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}} >
<Button
title="Buzz!"
onPress={ReactNativeHapticFeedback.trigger("selection")} />
</View>
);
};
export default App;
iOS 14.8 | React Native 0.66.0
Open up android/app/src/main/java/[...]/MainActivity.java
i wonder if that should be
Open up android/app/src/main/java/[...]/MainApplication.java
since i only see getPackages() in the latter.
Hi,
Would you mind adding an MIT license file into the body of this repository? Your NPM registry and package.json declare it as MIT licensed, but I don't see one in the repository, and I don't think I can use this code base without that. I think Github has a button on the repo settings to do that for you.
Thanks!
Today we have started to see this issue :
':react-native-haptic-feedback'.
> Could not resolve all artifacts for configuration ':react-native-haptic-feedback:classpath'.
> Could not resolve com.android.tools.build:builder:3.0.0.
Required by:
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0
> Could not resolve com.android.tools.build:builder:3.0.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/builder/3.0.0/builder-3.0.0.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/builder/3.0.0/builder-3.0.0.pom'.
> Read timed out
> Could not resolve org.eclipse.jdt.core.compiler:ecj:4.6.1.
Required by:
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0 > com.android.tools.lint:lint:26.0.0
> Skipped due to earlier error
> Could not resolve com.google.code.gson:gson:2.3.
Required by:
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0 > com.android.tools.lint:lint:26.0.0 > com.android.tools.build:manifest-merger:26.0.0
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0 > com.android.tools.lint:lint:26.0.0 > com.android.tools.build:manifest-merger:26.0.0 > com.android.tools:sdklib:26.0.0
> Skipped due to earlier error
> Could not resolve com.google.errorprone:error_prone_annotations:2.0.18.
Required by:
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0 > com.android.tools.build:gradle-api:3.0.0 > com.google.guava:guava:22.0
> Skipped due to earlier error
> Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.1.3-2.
Required by:
project :react-native-haptic-feedback > com.android.tools.build:gradle:3.0.0 > com.android.tools.build:gradle-core:3.0.0 > com.android.tools.lint:lint:26.0.0 > com.android.tools.lint:lint-checks:26.0.0 > com.android.tools.lint:lint-api:26.0.0
> Skipped due to earlier error
Is there any workaround on this?
Thank you in advance!
Can this library support rigid haptic feedback on iOS?
https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle/uiimpactfeedbackstylerigid
What are versions 2.0.1 and 2.0.2? They are not listed in Releases or tags, but they exist in npm.
There seems to be a massive amount of changes since version 2.0.0: https://diff.intrinsic.com/react-native-haptic-feedback/2.0.0/2.0.2
A key feature of Android buttons are the subtle sound and haptic they produce as feedback to touches.
Using your amazing library is the closest I've come to reproducing that.
On native android, the feedback is generated immediately as the touch is encountered.
But in react-native, when I use your ReactNativeHapticFeedback.trigger('selection')
on a onPress, the feedback only comes on the release of the touch. Is there a way to work around this?
Also, as a feature request, can you have a sound to play on Android devices, thus completing the circle of native feedback
Is it possible for this package to enable React Native Autolinking? https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
Not sure what would be needed for it, but since almost every package out there these days does it, it shouldn't be that hard i guess ;-)
Now we always get this error when running/building the app:
How do others deal with this? Just ignore it? ^_^
Edit: Android autolinking works. It only needs a few changes for iOS (podfiles). We now use this to mute the error: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library
When digging into the code for Android I saw you are using the Android Vibration API. The haptic feedback on Android right now is very aggressive and a lot more 'in your face' than the nice subtle haptics on iOS delivered by UIImpactFeedbackGenerator
.
There are APIs available for Android that use Haptics which allow for much more subtle feedback patterns:
Is there a specific reason for this choice? Otherwise, it might be interesting to implement this (I'd be happy to help via PR)
Environment:
React-Native: 0.57.7
OS: MacOS
How to reproduce:
Run the following script:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
Log:
node_modules/react-native-haptic-feedback/index.js: Unexpected token (22:19)
22 | const triggerHaptic(type, options) {
^
23 | try {
24 | NativeModules.RNReactNativeHapticFeedback.trigger(type, options);
25 | } catch (err) {
on build the error
'value' is unavailable: introduced in iOS 12.0
is shown
the podfile needs to be adapted to
s.platform= :ios, "12.4"
I switched from my custom haptic feedback solution to this library because I don't have time to maintain my own library, and noticed worse performance using this library when activating a series of rapid haptic (light impact) vibrations. After comparing with my code, my bet is that it is because on iOS, you allocate a new generator object every time the method is called. Instead, for best performance, you should only create one generator object for each type of feedback and re-use that object for future calls of the same time. This should create faster response time and take less energy. I'll create a PR for this later if I have time, but figured I'd mention it in case you want to take it on instead. Hopefully this makes sense, I can provide more details if needed.
it is working fine in all high end ios and all android but not working on low end ios,
i am using this code
ReactNativeHapticFeedback.trigger('notificationWarning', true);
please suggest
Is there a way to detect if your device has haptics? Getting a persistent warning on Simulator when using this library which I would like to avoid.
Please, add supports for react native macos
Hi,
I'm creating a swipe selector for a project and I was using this library to get a native feedback on iOS device, and it seems that when I swipe too quickly this library is called many times and it is causing some issues, causing the app to crash.
Enqueued from CHHapticEngineDispatchQueue
Anyone got this before ?
Hi,
I tested the package and it works fine on android.But nothing work on IPhone8.
I tried all parameters of the method. I don't get any errors or warnings on the console.
haptic() {
const hapticOptions = {
enableVibrateFallback: false,
ignoreAndroidSystemSettings: true,
};
const hapticTriggerType = Platform.select({
ios: 'selection',
android: 'notificationSuccess'
});
ReactNativeHapticFeedback.trigger(hapticTriggerType, hapticOptions)
}
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-haptic-feedback": "^1.13.0"
Model name: iPhone8
Software Version: 14.5.1
The library has hard-coded minSdkVersion
to be 16, instead of pulling it from the root project. This causes our Android Detox build to fail. (Not sure why the main build works but Detox build fails.)
I have a PR to fix the issue. In the meantime one can use "react-native-haptic-feedback": "github:plaa/react-native-haptic-feedback"
Hey! I want to use haptic vibration once button tap but I have faced weird issue.
When click button I am getting warning and haptic vibration is not working.
"react-native": "0.70.1",
"react-native-haptic-feedback": "^1.14.0",
Usage:
const onHeptic = () => ReactNativeHapticFeedback.trigger('impactMedium', options);
Is this package has any problem?
This does not seem to be working on iOS 13, has anyone been experiencing the same issues?
Hi,
I just installed on my new react native project. I have cd to pod
to install as well but I'm having this warning at below
do you have any solution for that?
react-native-haptic-feedback : ^1.8.2
System:
OS: macOS 10.15.1
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 27.80 MB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.16.3 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
After upgrading to v2.2.0 we are getting the following error during the build process.
We've tried manually setting up iOS based on the docs but when we attempt to add RNReactNativeHapticFeedback.xcodeproj
to the Libraries and move to the next step, it does not show up when we attempt to 'Link Binary To Libraries'. libRNReactNativeHapticFeedback.a
is not listed as one of the libraries available.
We can also confirm that attempting to click on RNReactNativeHapticFeedback.xcodeproj
in the Library dropdown yields a 'The file could not be opened.' popup.
This error also goes away if we manually link the Audiotoolbox.framework to the package. Any help would be appreciated.
hey developers,
I've discovered that the documentation for passing options value contains a small problem.
const options = {
enableVibrateFallback: true,
ignoreAndroidSystemSettings: false,
};
passing these as options doesn't perform haptic feedback which is mention in docs
insead,
const options = {
enableVibrateFallback: false,
ignoreAndroidSystemSettings: true,
};
by passing these as options it is performing haptic feedback
i request you to check docs and perform necessary changes
That's working and confirmed on Nexus/Pixel phones, some Huawei, etc, but isn't working for Samsung Galaxy phones and we should cover this segment.
Used to work perfectly, but now there is no haptic feedback on iPhone X running iOS 11.3. Adding the boolean argument "true" results in the heavy vibration.
No vibration can be produced otherwise.
The react-native-haptic-feedback library is not working with the latest version. Despite implementing the code as documented, no haptic feedback is being generated and there are no errors or warnings being displayed when interacting with components.
Hello. Are there any plans to update this library to support TurboModules? If so, is there anything we can help with?
compile method is deprecated. We should use 'implementation' instead.
Caused by java.lang.NoSuchMethodError
No static method createPredefined(I)Landroid/os/VibrationEffect; in class Landroid/os/VibrationEffect;
or its super classes (declaration of 'android.os.VibrationEffect' appears in /system/framework/framework.jar)
com.mkuczera.VibrateWithCreatePredefined.apply (VibrateWithCreatePredefined.java:20)
Getting this error on iOS:
Unknown argument type 'Boolean'. Extend RCTConvert to support this type.
Changing the argument to type BOOL
(supported by RCTConvert natively) fixes the issue.
Hi,
I'm using your library and it's a pretty good library.
But I've issues with some of my users, as you can see, this error is raise.
NSInternalInconsistencyException: Invalid configuration class (null) for generator <UIImpactFeedbackGenerator: 0x282784e10: prepared=0>
User running on IOS 12.4.1(16G102)
I don't know if you have any idea about that ?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.