diff --git a/docs/Reference.md b/docs/Reference.md index fd9e102..9065eba 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -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`. diff --git a/ios/RNCWKWebView.h b/ios/RNCWKWebView.h index 1b61c28..7a54c52 100644 --- a/ios/RNCWKWebView.h +++ b/ios/RNCWKWebView.h @@ -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; diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index ea7863f..b4e3a59 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -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 diff --git a/ios/RNCWKWebViewManager.m b/ios/RNCWKWebViewManager.m index 6585297..d4408f2 100644 --- a/ios/RNCWKWebViewManager.m +++ b/ios/RNCWKWebViewManager.m @@ -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)