mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 11:57:46 +08:00
Merge pull request #493 from tjwudi/patch-1
Add import RCTBridge.h for event sending example
This commit is contained in:
@@ -177,12 +177,21 @@ Note that the constants are exported only at initialization time, so if you chan
|
||||
The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use `eventDispatcher`:
|
||||
|
||||
```objective-c
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
|
||||
@implementation CalendarManager
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
- (void)calendarEventReminderReceived:(NSNotification *)notification
|
||||
{
|
||||
NSString *eventName = notification.userInfo[@"name"];
|
||||
[self.bridge.eventDispatcher sendAppEventWithName:@"EventReminder"
|
||||
body:@{@"name": eventName}];
|
||||
}
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
JavaScript code can subscribe to these events:
|
||||
|
||||
Reference in New Issue
Block a user