shinybrowser (version 1.0.0)

get_device: Get user's device (mobile or desktop)

Description

The value is reactive, therefore it must be accessed inside a reactive context (such as an observe or reactive). {shinybrowser} must be initialized with a call to detect() in the app's ui.

Usage

get_device()

Arguments

Value

User's detected decive type ("Mobile" or "Desktop")

Accuracy

It's important to understand there is no reliable way to detect the information in {shinybrowser} with 100% accuracy.{shinybrowser} makes a best effort at identifying the most accurate information, but some browser/operating system combinations may be difficult to identify. Users can also use a variety of tools to deliberately spoof this information. With that in mind, {shinybrowser} should detect the correct information in most cases.

Mobile vs desktop vs tablet

{shinybrowser} attempts to detect whether a device is "mobile" or "desktop". The distinction between mobile and desktop is not always clear, so if what you actually care about is the size of the device, it might be better to use get_width(). Tablets return ambiguous results; some tablets self-report as mobile devices while others as desktop.

See Also

detect(), get_all_info(), is_device_mobile(), is_device_desktop(), get_width(), get_height()

Examples

Run this code
# NOT RUN {
if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    shinybrowser::detect(),
    "Your device:",
    textOutput("device_info")
  )
  server <- function(input, output, session) {
    output$device_info <- renderText({
      shinybrowser::get_device()
    })
  }
  shinyApp(ui, server)
}
# }

Run the code above in your browser using DataLab