2015-03-23 15:07:33 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-03-23 15:07:33 -07:00
|
|
|
*/
|
2015-03-14 10:52:40 -07:00
|
|
|
|
2016-11-23 07:47:52 -08:00
|
|
|
#import <React/RCTView.h>
|
2015-03-14 10:52:40 -07:00
|
|
|
|
2015-11-04 08:42:28 -08:00
|
|
|
@class RCTWebView;
|
|
|
|
|
2015-07-31 11:23:29 -07:00
|
|
|
/**
|
|
|
|
* Special scheme used to pass messages to the injectedJavaScript
|
|
|
|
* code without triggering a page load. Usage:
|
|
|
|
*
|
|
|
|
* window.location.href = RCTJSNavigationScheme + '://hello'
|
|
|
|
*/
|
2015-07-01 18:06:39 -07:00
|
|
|
extern NSString *const RCTJSNavigationScheme;
|
|
|
|
|
2015-11-04 08:42:28 -08:00
|
|
|
@protocol RCTWebViewDelegate <NSObject>
|
|
|
|
|
|
|
|
- (BOOL)webView:(RCTWebView *)webView
|
2015-11-14 10:25:00 -08:00
|
|
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
2015-11-04 08:42:28 -08:00
|
|
|
withCallback:(RCTDirectEventBlock)callback;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-03-14 10:52:40 -07:00
|
|
|
@interface RCTWebView : RCTView
|
|
|
|
|
2015-11-04 08:42:28 -08:00
|
|
|
@property (nonatomic, weak) id<RCTWebViewDelegate> delegate;
|
|
|
|
|
2016-02-01 18:00:18 -08:00
|
|
|
@property (nonatomic, copy) NSDictionary *source;
|
2015-03-14 10:52:40 -07:00
|
|
|
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
|
|
|
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
2016-10-16 06:29:14 -07:00
|
|
|
@property (nonatomic, assign) BOOL messagingEnabled;
|
2015-07-07 17:07:52 -07:00
|
|
|
@property (nonatomic, copy) NSString *injectedJavaScript;
|
2016-02-26 08:19:40 -08:00
|
|
|
@property (nonatomic, assign) BOOL scalesPageToFit;
|
2015-03-14 10:52:40 -07:00
|
|
|
|
|
|
|
- (void)goForward;
|
|
|
|
- (void)goBack;
|
|
|
|
- (void)reload;
|
Implemented stopLoading
Summary:**Motivation:** In my app, I'm using a WebView that loads content from my mobile site. What I want to do is when a user presses a link on the loaded page, I want to stop the WebView's request, hijack the URL and open the URL in a new WebView, pushed to the top of the navigator stack. To me, this gives the overall app a more native feel, instead of implementing a rudimentary navbar on the main WebView to go back.
**Attempted Workarounds:** I've attempted to get similar functionality by capturing the onNavigationStateChange event in the WebView, and then within calling goBack + pushing the new view to the navigator stack. From a functionality standpoint, this works. However, from a UI standpoint, the user can clearly see the webview change states to a new page + go back before having the new view pushed on top of their nav stack.
Closes https://github.com/facebook/react-native/pull/6886
Differential Revision: D3212447
Pulled By: mkonicek
fb-gh-sync-id: 05911e583d9ba54ddbd54a772153c80ed227731e
fbshipit-source-id: 05911e583d9ba54ddbd54a772153c80ed227731e
2016-04-22 08:14:53 -07:00
|
|
|
- (void)stopLoading;
|
2016-10-16 06:29:14 -07:00
|
|
|
- (void)postMessage:(NSString *)message;
|
2017-01-06 20:13:20 -08:00
|
|
|
- (void)injectJavaScript:(NSString *)script;
|
2015-03-14 10:52:40 -07:00
|
|
|
|
|
|
|
@end
|