Browse Source

feat(iOS WKWebView): Add mainDocumentURL to onShouldStartLoadWithRequest(#493)

* Pass mainDocumentURL to onShouldStartLoadWithRequest

* Update reference

* Update typescript types

* Update WebViewTypes.ts
Penar Musaraj 5 years ago
parent
commit
71d1fcc675
4 changed files with 4 additions and 0 deletions
  1. 1
    0
      docs/Reference.md
  2. 1
    0
      ios/RNCUIWebView.m
  3. 1
    0
      ios/RNCWKWebView.m
  4. 1
    0
      src/WebViewTypes.ts

+ 1
- 0
docs/Reference.md View File

@@ -496,6 +496,7 @@ target
496 496
 canGoBack
497 497
 canGoForward
498 498
 lockIdentifier
499
+mainDocumentURL (iOS only)
499 500
 navigationType
500 501
 ```
501 502
 

+ 1
- 0
ios/RNCUIWebView.m View File

@@ -214,6 +214,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
214 214
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
215 215
     [event addEntriesFromDictionary: @{
216 216
       @"url": (request.URL).absoluteString,
217
+      @"mainDocumentURL": (request.mainDocumentURL).absoluteString,
217 218
       @"navigationType": navigationTypes[@(navigationType)]
218 219
     }];
219 220
     if (![self.delegate webView:self

+ 1
- 0
ios/RNCWKWebView.m View File

@@ -721,6 +721,7 @@ static NSURLCredential* clientAuthenticationCredential;
721 721
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
722 722
     [event addEntriesFromDictionary: @{
723 723
       @"url": (request.URL).absoluteString,
724
+      @"mainDocumentURL": (request.mainDocumentURL).absoluteString,
724 725
       @"navigationType": navigationTypes[@(navigationType)]
725 726
     }];
726 727
     if (![self.delegate webView:self

+ 1
- 0
src/WebViewTypes.ts View File

@@ -104,6 +104,7 @@ export interface WebViewNavigation extends WebViewNativeEvent {
104 104
     | 'reload'
105 105
     | 'formresubmit'
106 106
     | 'other';
107
+  mainDocumentURL?: string;
107 108
 }
108 109
 
109 110
 export type DecelerationRateConstant = 'normal' | 'fast';