c++ – ReactNative iOS sendEventWithName trigger “RCTCallableJSModules isn’t set”


i’ve the next state of affairs.

2 similar react-native apps (differs just for bundleId, app icon and many others) structured like this:

-> challenge construction

My objective it is to emit an occasion from native aspect to the JS layer by means of the bridge when a push notification has been obtained or tapped by the person (assuming that the app is in foreground and app has completed launching).
On the primary App the next code works as anticipated when i set off a push notification to my simulator with the command xcrun simctl push <device-id> <bundleId> <filename>.apns, the second app crash immediatly with the next error:

Thread 1: "Error when sending occasion: pushDelivered with physique: <the string handed as physique>. RCTCallableJSModules isn't set. That is in all probability since you've explicitly synthesized the RCTCallableJSModules in CustomEventsEmitter, regardless that it is inherited from RCTEventEmitter."

-> xcode view

Right here is the code implementation of RCTEventEmitter’s sendEventWithName that provoke the assertion.

I do not know if it is an issue with my implementation. In 1 of the two apps works like a allure, within the different 💥.
Anybody may also help me discover the issue within the code ? In all probability an issue with the bridge?

i’ve tried many instances to reinstall pods, clear challenge and rebuild. The code works on the challenge A and never on the challenge B.. i can not determine the rationale


#import <React/RCTBridgeDelegate.h>
#import <React/RCTBridgeModule.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <UserNotifications/UNUserNotificationCenter.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, RCTBridgeModule, UNUserNotificationCenterDelegate>

@property (nonatomic, robust) UIWindow *window;
@property (nonatomic, robust) NSDictionary *receivedNotificationUserInfo;



#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <React/RCTAppSetupUtils.h>
#import <UserNotifications/UserNotifications.h>

#import "CustomEventsEmitter.h"

@implementation AppDelegate

bool hasFinishedLaunching = false;
CustomEventsEmitter *customEventsEmitter = NULL;

- (BOOL)utility:(UIApplication *)utility didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  hasFinishedLaunching = true;
  customEventsEmitter = [CustomEventsEmitter allocWithZone: nil];


  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

  NSDictionary *initProps = [self prepareInitialProps];
  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"MyAppName", initProps);

  if (@accessible(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  // Outline UNUserNotificationCenter
  UNUserNotificationCenter *middle = [UNUserNotificationCenter currentNotificationCenter];
  middle.delegate = self;

  return YES;

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
  return [[NSBundle mainBundle] URLForResource:@"most important" withExtension:@"jsbundle"];

-(void)applicationDidBecomeActive:(UIApplication *)utility
  utility.applicationIconBadgeNumber = 0;

// The tactic shall be known as on the delegate when the person responded to the notification by opening
// the appliance, dismissing the notification or selecting a UNNotificationAction. The delegate
// should be set earlier than the appliance returns from applicationDidFinishLaunching:.
- (void)userNotificationCenter:(UNUserNotificationCenter *)middle
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler {

  NSLog(@"didReceiveNotificationResponse response: %@", response);
  NSDictionary *userInfo = response.notification.request.content material.userInfo;
  if (userInfo[@"_od"]){

    // if no listeners has been registered but, retailer the worth
    // that is the case when the notification was clicked from closed app
    if(![customEventsEmitter hasListeners]) {
      // deal with this case ...
    // if listeners has been registered, emit an occasion
    // that is the case when the notification was clicked from foreground app
    else {
      [self emitPushTappedEvent:userInfo[@"_od"]];


  if (completionHandler != nil) {

//Known as when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)middle
      willPresentNotification:(UNNotification *)notification
        withCompletionHandler:(void (^)(UNNotificationPresentationOptions choices))completionHandler

-(void)emitPushDeliveredEvent:(NSString*)worth {
  NSLog(@"emitPushDeliveredEvent known as");
  [customEventsEmitter sendEventWithName:@"pushDelivered" body:value];

-(void)emitPushTappedEvent:(NSString*)worth {
  NSLog(@"emitPushTappedEvent known as");
  [customEventsEmitter sendEventWithName:@"pushTapped" body:value];


And this are the CustomEventsEmitter recordsdata:


#ifndef CustomEventsEmitter_h
#outline CustomEventsEmitter_h

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

@interface CustomEventsEmitter : RCTEventEmitter <RCTBridgeModule>

- (void)sendEventName:(NSString *)eventName physique:(id)physique;
- (bool)hasListeners;




#import "CustomEventsEmitter.h"

@implementation CustomEventsEmitter
  bool hasListeners;


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

- (NSArray<NSString *> *)supportedEvents {
  return @[@"pushDelivered", @"pushTapped"];

// Shall be known as when this module's first listener is added.
-(void)startObserving {
  hasListeners = YES;
  // Arrange any upstream listeners or background duties as obligatory

// Shall be known as when this module's final listener is eliminated, or on dealloc.
-(void)stopObserving {
  hasListeners = NO;
  // Take away upstream listeners, cease pointless background duties

-(bool)hasListeners {
  return hasListeners;

- (void)sendEventName:(NSString *)eventName physique:(id)physique {
  if (hasListeners) {
    NSLog(@"CustomEventsEmitter sendEventName emitting occasion: %@", eventName);
    [self sendEventWithName:eventName   body:body];
  } else {
    NSLog(@"CustomEventsEmitter sendEventName known as with out listeners: %@", eventName);




Leave a Reply