Monday, August 15, 2022
HomeiOS DevelopmentReact Native - IOS ScreenRecordingListener Native Module error: Bridge just isn't set

React Native – IOS ScreenRecordingListener Native Module error: Bridge just isn’t set

[ad_1]

I’ve created a module for listening when a display screen document occasion is trigered however I hold getting this error: Bridge just isn’t set. That is in all probability since you’ve explicitly synthesized the bridge in ScreenCaptureNotification, though 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 take advantage of 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 (@out there(iOS 11.0, *)) {
        ScreenCaptureNotification *supervisor = [ScreenCaptureNotification allocWithZone: nil];
        [manager isScreenCaptureEnabled:true];
        
        
      }
    }
}

This code is predicated on this put up’s reply stop display screen seize react-native

Can somebody assist me with this error please? I have been caught for days

[ad_2]

RELATED ARTICLES

Most Popular

Recent Comments