Customizing User Agent
The user agent string identifies the client software originating a HTTP request, such as a web browser or app. By default, WebToNative (W2N) apps append specific strings to the end of the device's default user agent. However, you can customize these strings to include your own identifiers or branding.
Default User Agent Strings:
- iOS App: The device's default user agent is appended with
w2n/iOS
. - Android App: The default device user agent is appended with
w2n/android
.
Custom User Agent:
-
Select Custom Option: In your app settings, choose the Custom option to specify a custom user agent.
-
Provide Custom User Agent: Enter your custom user agent string. This string will replace the default identifier appended to the user agent.
Usage and Recognition:
- The user agent, including any customizations, is sent in the headers of each HTTP request originating from the app.
- Recognition of requests from your app can be achieved by checking if the user agent contains specific identifiers like
w2n
.
Accessing User Agent via JavaScript:
- Utilize JavaScript to access the user agent directly using
navigator.userAgent
.
JavaScript Filter Logic Example:
if (navigator.userAgent.indexOf('w2n') > -1) {
// Perform actions specific to your app
}