push: Notification with push.js

Description Usage Arguments Note Examples

View source: R/push.R

Description

Initialize with use_push in UI before using push server-side. Close all notifications with push_close.

Usage

1
2
3
4
5
6
push(
  title,
  text = NULL,
  timeout = 4000,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

title

Title of the notification.

text

Optional text for the notification.

timeout

Time in milliseconds until the notification closes automatically.

session

Shiny session.

Note

push.js sends desktop notifications, user need to allow permission to show notification.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(shiny)
library(shinypop)

ui <- fluidPage(
  tags$h2("Push notification"),
  use_push(),
  actionButton("show", "Show notification"),
  textInput("title", "Text to display", "Hello world :)")
)

server <- function(input, output, session) {
  
  observeEvent(input$show, {
    push(title = input$title)
  })
  
}

if (interactive()) 
  shinyApp(ui, server)

dreamRs/shinypop documentation built on Oct. 18, 2021, 8:28 p.m.