React Native – IOS ScreenRecordingListener Native Module error: Bridge shouldn’t be set

[ad_1]

I’ve created a module for listening when a display screen report occasion is trigered however I hold getting this error: Bridge shouldn’t be set. That is most likely since you’ve explicitly synthesized the bridge in ScreenCaptureNotification, despite the fact that it is inherited from RCTEventEmitter.’

That is my header file: ScreenRecordingNotification.h

#import <React/RCTBridgeModule.h>
#import <React/RCTBridgeDelegate.h>
#import <React/RCTEventEmitter.h>

#ifndef ScreenCaptureNotification_h
#outline ScreenCaptureNotification_h

@interface ScreenCaptureNotification : RCTEventEmitter <RCTBridgeModule>
-(void) isScreenCaptureEnabled:(BOOL)isCaptured;
@finish

#endif

and my Goal-c file: ScreenCaptureNotification.m

#import "ScreenRecordingNotification.h"

#import <Basis/Basis.h>

#import <React/RCTLog.h>

@implementation ScreenCaptureNotification

+ (id)allocWithZone:(NSZone *)zone {
  static ScreenCaptureNotification *sharedInstance = nil;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    sharedInstance = [super allocWithZone:zone];
  });
  return sharedInstance;
}

RCT_EXPORT_MODULE();

- (NSArray<NSString *> *)supportedEvents {
  return @[@"isScreenCaptureEnabled"];
}

-(void) isScreenCaptureEnabled:(BOOL)isCaptured {
  [self sendEventWithName:@"isScreenCaptureEnabled" body:@{@"value": @(isCaptured)}];
}

@finish

Lastly I exploit the module on AppDelegate.m

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if ([keyPath isEqualToString:@"captured"]){
      NSLog(@"Display Seize is Enabled");
      RCTLog(@"Display Seize is Enabled");
      if (@accessible(iOS 11.0, *)) {
        ScreenCaptureNotification *supervisor = [ScreenCaptureNotification allocWithZone: nil];
        [manager isScreenCaptureEnabled:true];
        
        
      }
    }
}

This code relies on this publish’s reply stop display screen seize react-native

[ad_2]

Leave a Reply