Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send event from iOS to javascript #8891

Closed
Arthraim opened this issue Jul 19, 2016 · 4 comments
Closed

How to send event from iOS to javascript #8891

Arthraim opened this issue Jul 19, 2016 · 4 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@Arthraim
Copy link

I'm doing something Async in iOS app, it's triggered by javascript. When it's done (somewhere separated in app), I want to let javascript know.
My current solution is a native module inherited from RCTEventEmitter, has a method like

@interface MyEventEmitter : RCTEventEmitter
// ...
end
@implementation
- (void)giveSomethingToJS:(NSString *)something {
  [self sendEventWithName:@"SOME_NAME" body:something];
}
@end

Then when my Async job's done, I call this method like

MyEventEmitter *emitter = [[MyEventEmitter alloc] init];
[emitter giveSomethingToJS:@{}];

And obviously, emitter.bridge is nil and app crashed because of assert bridge != nil. So how am I get the bridge and let *emitter(the instance) know. Or how can I get the right instance with bridge initialized?

Thanks in advance!

@Arthraim Arthraim changed the title How to sendEvent from iOS to javascript How to send event from iOS to javascript Jul 19, 2016
@charpeni
Copy link
Contributor

@facebook-github-bot stack-overflow

@ghost
Copy link

ghost commented Jul 19, 2016

Hey @Arthraim and thanks for posting this! @charpeni tells me this issue looks like a question that would be best asked on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. Will close this as this is really a question that should be asked on SO.

@ghost ghost added the For Stack Overflow label Jul 19, 2016
@ghost ghost closed this as completed Jul 19, 2016
@ghost ghost added the Ran Commands One of our bots successfully processed a command. label Jul 19, 2016
@purplepeng
Copy link

purplepeng commented Jul 20, 2016

I have the same problem. Have you resolve the problem? @Arthraim

@purplepeng
Copy link

purplepeng commented Jul 22, 2016

Thank you. I have resolve the problem. The issue seems to same this

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants