mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 13:44:04 +00:00
Expose environment and arguments to JS
Summary: Right now from JS there's no way to see the environment variables or arguments that the application was started with. The main use case for this is to help enable/disable features when being run in a testing environment (as environment variables are the easiest way to communicate). javache is it okay to reference these constants from JS at startup time? I am planning to disable yellow boxes via an environment variable. achen1 how easy is it expose these two things for Android as well? Reviewed By: achen1 Differential Revision: D4395091 fbshipit-source-id: fc318e6a60b8829f7eb4491ea8f3258f68f59c8c
This commit is contained in:
parent
09072b9d77
commit
91b7499cf6
15
React/Modules/RCTProcessInfo.h
Normal file
15
React/Modules/RCTProcessInfo.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
@interface RCTProcessInfo : NSObject <RCTBridgeModule>
|
||||
|
||||
@end
|
26
React/Modules/RCTProcessInfo.m
Normal file
26
React/Modules/RCTProcessInfo.m
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTProcessInfo.h"
|
||||
|
||||
@implementation RCTProcessInfo
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
return
|
||||
@{
|
||||
@"environment": processInfo.environment,
|
||||
@"arguments": processInfo.arguments,
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
Loading…
x
Reference in New Issue
Block a user