File tree Expand file tree Collapse file tree 4 files changed +33
-16
lines changed
RNHapticFeedback.xcodeproj Expand file tree Collapse file tree 4 files changed +33
-16
lines changed Original file line number Diff line number Diff line change 2525
2626/* Begin PBXFileReference section */
2727 134814201AA4EA6300B7C361 /* libRNHapticFeedback.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNHapticFeedback.a; sourceTree = BUILT_PRODUCTS_DIR; };
28+ 3FAF13E52C6144D7002E28B1 /* RNHapticFeedbackSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNHapticFeedbackSpec.h; path = RNHapticFeedback/RNHapticFeedbackSpec.h; sourceTree = "<group>"; };
2829 558CBA9028EF1100007CF242 /* RNHapticFeedback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNHapticFeedback.h; path = RNHapticFeedback/RNHapticFeedback.h; sourceTree = "<group>"; };
2930 558CBA9128EF1100007CF242 /* DeviceUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeviceUtils.h; path = RNHapticFeedback/DeviceUtils.h; sourceTree = "<group>"; };
3031 558CBA9228EF1100007CF242 /* DeviceUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeviceUtils.mm; path = RNHapticFeedback/DeviceUtils.mm; sourceTree = "<group>"; };
5354 58B511D21A9E6C8500147676 = {
5455 isa = PBXGroup;
5556 children = (
57+ 3FAF13E52C6144D7002E28B1 /* RNHapticFeedbackSpec.h */,
5658 558CBA9128EF1100007CF242 /* DeviceUtils.h */,
5759 558CBA9228EF1100007CF242 /* DeviceUtils.mm */,
5860 558CBA9028EF1100007CF242 /* RNHapticFeedback.h */,
Original file line number Diff line number Diff line change 1- // Thanks to this guard, we won't import this header when we build for the old architecture.
21#ifdef RCT_NEW_ARCH_ENABLED
32#import " RNHapticFeedbackSpec.h"
3+
4+ @interface RNHapticFeedback : NSObject <NativeHapticFeedbackSpec>
45#else
56#import < React/RCTBridgeModule.h>
7+
8+ @interface RNHapticFeedback : NSObject <RCTBridgeModule>
69#endif
710
811#import < Foundation/Foundation.h>
912#import < UIKit/UIKit.h>
1013
11- #ifdef RCT_NEW_ARCH_ENABLED
12- @interface RNHapticFeedback : NSObject <NativeHapticFeedbackSpec>
13- #else
14- @interface RNHapticFeedback : NSObject <RCTBridgeModule>
15- #endif
16-
17- typedef enum {
14+ typedef NS_ENUM (NSInteger , FeedbackType) {
1815 selection,
1916 impactLight,
2017 impactMedium,
@@ -24,9 +21,9 @@ typedef enum {
2421 notificationSuccess,
2522 notificationWarning,
2623 notificationError
27- }FeedbackType ;
24+ };
2825
2926- (Boolean)supportsHaptic ;
27+ - (void )triggerHapticFeedback : (NSString *)feedbackType ;
3028
31- @end
32-
29+ @end
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ @implementation RNHapticFeedback
1414
1515- (void )setBridge : (RCTBridge *)bridge
1616{
17- _bridge = bridge;
17+ @synthesize _bridge = bridge;
1818}
1919
2020- (dispatch_queue_t )methodQueue
@@ -31,7 +31,7 @@ - (dispatch_queue_t)methodQueue
3131#else
3232RCT_EXPORT_METHOD (trigger:(NSString *)type options:(NSDictionary *)options)
3333{
34- BOOL enableVibrateFallback = [[options objectForKey: @" enableVibrateFallback" ]boolValue];
34+ BOOL enableVibrateFallback = [[options objectForKey: @" enableVibrateFallback" ] boolValue ];
3535#endif
3636
3737 if ([self supportsHaptic ]){
@@ -118,11 +118,11 @@ -(void)generateNotificationFeedback:(UINotificationFeedbackType)notificationType
118118
119119// Thanks to this guard, we won't compile this code when we build for the old architecture.
120120#ifdef RCT_NEW_ARCH_ENABLED
121- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
122- (const facebook::react::ObjCTurboModule::InitParams &)params
123- {
121+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule: (const facebook::react::ObjCTurboModule::InitParams &)params {
124122 return std::make_shared<facebook::react::NativeHapticFeedbackSpecJSI>(params);
125123}
126124#endif
127125
128126@end
127+ @end
128+
Original file line number Diff line number Diff line change 1+ //
2+ // RNHapticFeedbackSpec.h
3+ // RNHapticFeedback
4+ //
5+ // Created by Michael Kuczera on 05.08.24.
6+ // Copyright © 2024 Facebook. All rights reserved.
7+ //
8+ #import < Foundation/Foundation.h>
9+
10+ @protocol NativeHapticFeedbackSpec <NSObject >
11+
12+ // Indicates whether the device supports haptic feedback
13+ - (Boolean)supportsHaptic ;
14+
15+ // Triggers haptic feedback with the given intensity
16+ - (void )triggerHapticFeedback : (NSString *)feedbackType ;
17+
18+ @end
You can’t perform that action at this time.
0 commit comments