User Agent get/set/reset plugin for Capacitor
npm install @adeprez/capacitor-user-agentUser Agent get/set/reset plugin for Capacitor
``bash`
npm install @adeprez/capacitor-user-agent
npx cap sync
`typescript
import { UserAgent } from '@adeprez/capacitor-user-agent';
async getMyUserAgent(): Promise
const result = await UserAgent.get();
return result.userAgent;
}
setMyUserAgent(userAgent: string): Promise
return UserAgent.set({userAgent});
}
`
`typescript`
get() => Promise<{ userAgent: string; }>
Get the Webview's user agent
Returns: Promise<{ userAgent: string; }>
--------------------
`typescript`
set(options: { userAgent: string; reloadOnChange?: boolean; }) => Promise
Update the Webview user agent (Android and iOS only). Set reloadOnChange
to true to reload the page when the user agent changes (default is false).
Starting from KITKAT Android version, changing the user-agent while loading
a web page causes WebView to initiate loading once again.
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | { userAgent: string; reloadOnChange?: boolean; } |
--------------------
`typescript``
reset() => Promise
Reset the Webview user agent (Android and iOS only)
--------------------