@adeprez/capacitor-user-agent
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@adeprez/capacitor-user-agent

User Agent get/set/reset plugin for Capacitor

Install

npm install @adeprez/capacitor-user-agent
npx cap sync

Usage

import { UserAgent } from '@adeprez/capacitor-user-agent';

async getMyUserAgent(): Promise<string> {
  const result = await UserAgent.get();
  return result.userAgent;
}

setMyUserAgent(userAgent: string): Promise<void> {
  return UserAgent.set({userAgent});
}

API

get()

get() => Promise<{ userAgent: string; }>

Get the Webview's user agent

Returns: Promise<{ userAgent: string; }>


set(...)

set(options: { userAgent: string; reloadOnChange?: boolean; }) => Promise<void>

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; }

reset()

reset() => Promise<void>

Reset the Webview user agent (Android and iOS only)


Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.3244latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.3244
0.1.20
0.1.10
0.1.03
0.0.40
0.0.3411
0.0.20
0.0.10

Package Sidebar

Install

npm i @adeprez/capacitor-user-agent

Weekly Downloads

658

Version

0.1.3

License

Apache-2.0

Unpacked Size

22.2 kB

Total Files

26

Last publish

Collaborators

  • adeprez