feat(iOS WkWebview): Add applicationNameForUserAgent support (#506)
This commit is contained in:
parent
7db138c0e5
commit
4dc4b89e64
|
@ -30,6 +30,7 @@ This document lays out the current public properties and methods for the React N
|
|||
- [`mixedContentMode`](Reference.md#mixedcontentmode)
|
||||
- [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled)
|
||||
- [`userAgent`](Reference.md#useragent)
|
||||
- [`applicationNameForUserAgent`](Reference.md#applicationNameForUserAgent)
|
||||
- [`allowsFullscreenVideo`](Reference.md#allowsfullscreenvideo)
|
||||
- [`allowsInlineMediaPlayback`](Reference.md#allowsinlinemediaplayback)
|
||||
- [`bounces`](Reference.md#bounces)
|
||||
|
@ -608,6 +609,14 @@ Sets the user-agent for the `WebView`. This will only work for iOS if you are us
|
|||
|
||||
---
|
||||
|
||||
### `applicationNameForUserAgent`
|
||||
|
||||
Append to the existing user-agent. Available on iOS WKWebView only. Setting `userAgent` will override this.
|
||||
|
||||
| Type | Required | Platform |
|
||||
| ------ | -------- | ------------- |
|
||||
| string | No | iOS WKWebView |
|
||||
|
||||
### `allowsFullscreenVideo`
|
||||
|
||||
Boolean that determines whether videos are allowed to be played in fullscreen. The default value is `false`.
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
@property (nonatomic, assign) BOOL incognito;
|
||||
@property (nonatomic, assign) BOOL useSharedProcessPool;
|
||||
@property (nonatomic, copy) NSString *userAgent;
|
||||
@property (nonatomic, copy) NSString *applicationNameForUserAgent;
|
||||
@property (nonatomic, assign) BOOL cacheEnabled;
|
||||
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
||||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||
|
|
|
@ -142,6 +142,10 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
wkWebViewConfig.mediaPlaybackRequiresUserAction = _mediaPlaybackRequiresUserAction;
|
||||
#endif
|
||||
|
||||
if (_applicationNameForUserAgent) {
|
||||
wkWebViewConfig.applicationNameForUserAgent = [NSString stringWithFormat:@"%@ %@", wkWebViewConfig.applicationNameForUserAgent, _applicationNameForUserAgent];
|
||||
}
|
||||
|
||||
if(_sharedCookiesEnabled) {
|
||||
// More info to sending cookies with WKWebView
|
||||
// https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303
|
||||
|
|
|
@ -48,6 +48,7 @@ RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
|
|||
RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(applicationNameForUserAgent, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
|
||||
|
||||
|
|
Loading…
Reference in New Issue