Skip to content

Instantly share code, notes, and snippets.

@garrettmac
Last active August 7, 2017 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrettmac/89e6dcb25784eea898a6cacbbe3748d2 to your computer and use it in GitHub Desktop.
Save garrettmac/89e6dcb25784eea898a6cacbbe3748d2 to your computer and use it in GitHub Desktop.
React-Native-Swift-Module-Starter.md
import {
NativeModules,
} from 'react-native';
console.log(" NativeModules: ",NativeModules);
// RNSocialKitBridge.m
#import <React/RCTBridgeModule.h>

@interface RCT_EXTERN_MODULE(RNSocialKit, NSObject)

RCT_EXTERN_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(nonnull NSNumber *)date)

@end
// RNSocialKit.swift

@objc(RNSocialKit)
class RNSocialKit: NSObject {

  @objc(addEvent:location:date:)
  func addEvent(name: String, location: String, date: NSNumber) -> Void {
    // Date is ready to use!
  }

}
// RNSocialKit-Bridging-Header.h
#import <React/RCTBridgeModule.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment