consider setting navigator.product to 'ReactNative' to match RN's webview?
henrylearn2rock opened this issue · comments
Apparently RN's <webview>
sets navigator.product
to 'ReactNative'. Please consider doing the same for compatibility?
That referenced issue was closed by committing a change to the RN core, so we can't fix it in the same way.
I would say that whatever the native navigator.product
is is technically the correct one; RN may be standardising it so that it matches across all platforms for the component, but for this project, it's guaranteed that we only have one platform: iOS (and technically macOS on my fork, but again, that'll share the same, native navigator.platform
as iOS).
Changing navigator.platform
can be achieved by injecting some JS atDocumentLoadStart
. This can be done by the user, or we can make a change to the repo to enforce it – however, I'm against the latter for the reasons above.
Is there any particular use case you're trying to address? Trying to get some context here.
I was looking for a reliable way of detecting whether the page is being rendered by RN's webview/wkwebview. One can check window.postMessage
has length of 1 (1 param), or if window.webkit.messageHandlers.reactNative.postMessage
exists. They both feel hackish so I googled and realized that webview can also be detected by checking if navigator.product
= "ReactNative"
.
Anyway, no big deal, but if one of the wkwebview goals is to be drop-in compatible with webview, it may be a good idea to follow what RN's webview does.