Created
January 3, 2018 05:19
-
-
Save himelnagrana/e8678737333925baf75c2200626c65d1 to your computer and use it in GitHub Desktop.
iOS Native Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <React/RCTBridgeModule.h> | |
@interface CalendarManager : NSObject <RCTBridgeModule> | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "CalendarManager.h" | |
#import <React/RCTLog.h> | |
@implementation CalendarManager | |
RCT_EXPORT_MODULE(EmpManCalendarManager); // for naming the module as CalendarManager just use `RCT_EXPORT_MODULE();` | |
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location) | |
{ | |
RCTLogInfo(@"Pretending to create an event %@ at %@", name, location); | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This exposes the native EmpManCalendarManager module as a JS module. This has a | |
* function 'addEvent' which takes the following parameters: | |
* | |
* 1. String name: A string for event name | |
* 2. string location: A string for event location | |
*/ | |
import {NativeModules} from 'react-native'; | |
module.exports = NativeModules.EmpManCalendarManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EmpManCalendarManager from './EmpManCalendarManager'; | |
if (Platform.OS == "ios") { | |
EmpManCalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment