Skip to content

Instantly share code, notes, and snippets.

@MacKentoch
Last active September 13, 2017 19:54
Show Gist options
  • Save MacKentoch/72eab1a43c2915c0be04ae7d62c479bf to your computer and use it in GitHub Desktop.
Save MacKentoch/72eab1a43c2915c0be04ae7d62c479bf to your computer and use it in GitHub Desktop.
/////////////////
// BRIDGE
/////////////////
// Device.h
@import UIKit;
#import <React/RCTBridgeModule.h>
@interface Device : NSObject <RCTBridgeModule>
@end
// Device.m
#import "Device.h"
@implementation Device
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(deviceName:(RCTResponseSenderBlock)callback) {
NSString *deviceName = [[UIDevice currentDevice] name];
callback(@[deviceName]);
}
@end
/////////////////
// JS
/////////////////
var Device = require('react-native').NativeModules.Device;
Device.deviceName( (name) => {
console.log(name)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment