Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React native app crashes on sendEventWithName

$
0
0

I am trying to send data from objective C to react native. I have already achieved that in other occasion with this function:

-(void)loginData:(NSString *) data
{
  [self sendEventWithName:@"loginOrRegister" body:data];
}

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

I tried to do it again with function:

-(void)editProfile:(BOOL) success
{
  [self sendEventWithName:@"editUserProfile" body:@{@"data": @(success)}];
}

but app crashes with "Thread 1: signal SIGABRT". I can't tell if I have forgotten something but I am pretty sure I haven't. I have tried to send a simple string but nothing.

In react-native i have an emitter like this:

const eventEmitter = new NativeEventEmitter(NativeModules.CosmoteIdHelper);
      eventEmitter.addListener('editUserProfile', (event) => {
                           ....

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>