feat(iOS WkWebview): Add applicationNameForUserAgent support (#506)

This commit is contained in:
Penar Musaraj 2019-05-20 18:01:22 -04:00 committed by Thibault Malbranche
parent 7db138c0e5
commit 4dc4b89e64
4 changed files with 15 additions and 0 deletions

View File

@ -30,6 +30,7 @@ This document lays out the current public properties and methods for the React N
- [`mixedContentMode`](Reference.md#mixedcontentmode) - [`mixedContentMode`](Reference.md#mixedcontentmode)
- [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled) - [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled)
- [`userAgent`](Reference.md#useragent) - [`userAgent`](Reference.md#useragent)
- [`applicationNameForUserAgent`](Reference.md#applicationNameForUserAgent)
- [`allowsFullscreenVideo`](Reference.md#allowsfullscreenvideo) - [`allowsFullscreenVideo`](Reference.md#allowsfullscreenvideo)
- [`allowsInlineMediaPlayback`](Reference.md#allowsinlinemediaplayback) - [`allowsInlineMediaPlayback`](Reference.md#allowsinlinemediaplayback)
- [`bounces`](Reference.md#bounces) - [`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` ### `allowsFullscreenVideo`
Boolean that determines whether videos are allowed to be played in fullscreen. The default value is `false`. Boolean that determines whether videos are allowed to be played in fullscreen. The default value is `false`.

View File

@ -43,6 +43,7 @@
@property (nonatomic, assign) BOOL incognito; @property (nonatomic, assign) BOOL incognito;
@property (nonatomic, assign) BOOL useSharedProcessPool; @property (nonatomic, assign) BOOL useSharedProcessPool;
@property (nonatomic, copy) NSString *userAgent; @property (nonatomic, copy) NSString *userAgent;
@property (nonatomic, copy) NSString *applicationNameForUserAgent;
@property (nonatomic, assign) BOOL cacheEnabled; @property (nonatomic, assign) BOOL cacheEnabled;
@property (nonatomic, assign) BOOL allowsLinkPreview; @property (nonatomic, assign) BOOL allowsLinkPreview;
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator; @property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;

View File

@ -142,6 +142,10 @@ static NSURLCredential* clientAuthenticationCredential;
wkWebViewConfig.mediaPlaybackRequiresUserAction = _mediaPlaybackRequiresUserAction; wkWebViewConfig.mediaPlaybackRequiresUserAction = _mediaPlaybackRequiresUserAction;
#endif #endif
if (_applicationNameForUserAgent) {
wkWebViewConfig.applicationNameForUserAgent = [NSString stringWithFormat:@"%@ %@", wkWebViewConfig.applicationNameForUserAgent, _applicationNameForUserAgent];
}
if(_sharedCookiesEnabled) { if(_sharedCookiesEnabled) {
// More info to sending cookies with WKWebView // 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 // https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303

View File

@ -48,6 +48,7 @@ RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL) RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString) RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
RCT_EXPORT_VIEW_PROPERTY(applicationNameForUserAgent, NSString)
RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL) RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)