Skip to content

arivera12/BlazorCurrentDevice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f69677e · Jul 27, 2022

History

36 Commits
May 28, 2020
Jun 10, 2021
Apr 5, 2020
Apr 5, 2020
May 28, 2020
May 29, 2020
Apr 20, 2020
Jul 27, 2022

Repository files navigation

BlazorCurrentDevice

Device detection for blazor using current-device.js

Installation

Install-Package BlazorCurrentDevice -Version 1.0.7

Add reference in _Imports.razor

@using BlazorCurrentDevice

Add the service in your services method

services.AddBlazorCurrentDevice();

Add javascript library reference in your index.html

<script src="_content/BlazorCurrentDevice/current-device.min.js"></script>

Usage

[Inject] IBlazorCurrentDeviceService BlazorCurrentDeviceService { get; set; }

Device Methods

BlazorCurrentDeviceService Method
Mobile BlazorCurrentDeviceService.Mobile()
Tablet BlazorCurrentDeviceService.Tablet()
Desktop BlazorCurrentDeviceService.Desktop()
iOS BlazorCurrentDeviceService.iOS()
iPad BlazorCurrentDeviceService.iPad()
iPhone BlazorCurrentDeviceService.iPhone()
iPod BlazorCurrentDeviceService.iPod()
Android BlazorCurrentDeviceService.Android()
Android Phone BlazorCurrentDeviceService.AndroidPhone()
Android Tablet BlazorCurrentDeviceService.AndroidTablet()
BlackBerry BlazorCurrentDeviceService.Blackberry()
BlackBerry Phone BlazorCurrentDeviceService.BlackberryPhone()
BlackBerry Tablet BlazorCurrentDeviceService.BlackberryTablet()
Windows BlazorCurrentDeviceService.Windows()
Windows Phone BlazorCurrentDeviceService.WindowsPhone()
Windows Tablet BlazorCurrentDeviceService.WindowsTablet()
Firefox OS BlazorCurrentDeviceService.FireFoxOs()
Firefox OS Phone BlazorCurrentDeviceService.FireFoxOsPhone()
Firefox OS Tablet BlazorCurrentDeviceService.FireFoxOsTablet()
MacOs BlazorCurrentDeviceService.MacOs()
MeeGo BlazorCurrentDeviceService.MeeGo()
NodeWebkit BlazorCurrentDeviceService.NodeWebkit()
Cordova BlazorCurrentDeviceService.Cordova()
Television BlazorCurrentDeviceService.Television()

Orientation Methods

Orientation Method
Landscape BlazorCurrentDeviceService.Landscape()
Portrait BlazorCurrentDeviceService.Portrait()

Useful Methods

Method Returns
BlazorCurrentDeviceService.Type() 'mobile', 'tablet', 'desktop', or 'unknown'
BlazorCurrentDeviceService.Orientation() 'landscape', 'portrait', or 'unknown'
BlazorCurrentDeviceService.OS() 'ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'macos', 'fxos', 'meego', 'television', or 'unknown'

TODO

  • Implement onChangeOrientation callback

License

MIT

About

Device detection for blazor using current-device.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published