[ReactNative] Allow JS know its URL
This commit is contained in:
parent
0e8bc08d3f
commit
2434512847
|
@ -88,6 +88,11 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method;
|
|||
url:(NSURL *)url
|
||||
onComplete:(RCTJavaScriptCompleteBlock)onComplete;
|
||||
|
||||
/**
|
||||
* URL of the script that was loaded into the bridge.
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSURL *bundleURL;
|
||||
|
||||
@property (nonatomic, strong) Class executorClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
#import "RCTSourceCode.h"
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTSourceCode
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
|
||||
failureCallback:(RCTResponseSenderBlock)failureCallback)
|
||||
{
|
||||
|
@ -26,4 +29,10 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
|
|||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
NSString *URL = [self.bridge.bundleURL absoluteString] ?: @"";
|
||||
return @{@"scriptURL": URL};
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue