User Agent
The UserAgent plugin provides functions to set the HTTP user-agent header. For more info about User-Agents, please see the HTTP User-Agent docs.
Requires Cordova plugin: cordova-useragent
. For more info, please see the User-Agent plugin docs.
https://github.com/danielsogl/cordova-plugin-useragent
Stuck on a Cordova issue?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.
Installation#
- Capacitor
- Cordova
- Enterprise
$ npm install cordova-plugin-useragent $ npm install @ionic-native/user-agent $ ionic cap sync
$ ionic cordova plugin add cordova-plugin-useragent $ npm install @ionic-native/user-agent
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us
#
Supported Platforms- Android
- iOS
#
Usage#
ReactLearn more about using Ionic Native components in React
#
Angularimport { UserAgent } from '@ionic-native/user-agent/ngx';
constructor(private userAgent: UserAgent) { }
...
this.userAgent.set('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36') .then((res: any) => console.log(res)) .catch((error: any) => console.error(error));
* this.userAgent.get() .then((res: any) => console.log(res)) .catch((error: any) => console.error(error));
* this.userAgent.reset() .then((res: any) => console.log(res)) .catch((error: any) => console.error(error));