Notifications

In osl notifications can only be sent at runtime using a running script. You cannot send notifications while no code is running.

To send a notification you need the "notifications" permission, to get this permission you must ask the user for it using the code below:

permission "request" "notifications"

This code will give your user a popup to allow or deny the permission request while your app continues running in the background. You may need to restart your program or continuously check the "permissions" variable for if it contains "notifications" using something like the code below:

permission "request" "notifications"
hasperms = false
mainloop:
if hasperms.not (
  // only check while you don't have permissions
  if window.permissions.contains("notifications") (
    hasperms = true
  ) else (
    exit
    // this stops the execution of the program for this frame
  )
)

Sending a notification

Notifications are not secure, please do not put sensitive info in them

Getting all notifications

With the notification permission you can also get an array of all notifications that the user has recieved since booting the device

Info on the notification array

Notifications are stored as an array of objects

Last updated

Was this helpful?