> For the complete documentation index, see [llms.txt](https://cylexdev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cylexdev.gitbook.io/docs/cylex-phone/exports-and-events/server-exports/notifications.md).

# Notifications

#### QueueNotificationForOffline <a href="#user-content-queuenotificationforoffline" id="user-content-queuenotificationforoffline"></a>

```lua
-- identifier: string - target identifier
-- notification: table - notification data table
-- return: boolean

-- Queues a persistent notification for an offline or online player.
-- Useful for lockscreen notifications. Will only persist apps defined in CategorySettings.

local notificationData = {
    text = "You have a new message!",
    _data = {
        app = "messages",
        sender = "1234567"
    }
}

exports['cylex_phone']:QueueNotificationForOffline(identifier, notificationData)
```

#### GetPendingNotifications <a href="#user-content-getpendingnotifications" id="user-content-getpendingnotifications"></a>

```lua
-- identifier: string - target identifier
-- return: table - Returns a table of pending persistent notifications

local pendingNotifs = exports['cylex_phone']:GetPendingNotifications(identifier)
```

#### ClearPendingNotifications <a href="#user-content-clearpendingnotifications" id="user-content-clearpendingnotifications"></a>

```lua
-- identifier: string - target identifier
-- return: boolean

-- Clears all pending/persistent lockscreen notifications for the target identifier.

local success = exports['cylex_phone']:ClearPendingNotifications(identifier)
```

#### PhoneNotification  <a href="#user-content-phonenotification-client-side" id="user-content-phonenotification-client-side"></a>

```lua
-- src: number - target player server id (source)
-- data: table - notification data parameters
-- return: none

-- Sends a notification to the phone.
-- If the app is defined in persistent settings, it will stay on the lockscreen.

local data = {
    title = "Bank",
    text = "You received $500!",
    icon = { name = 'app-icon/bank.png' }, -- Icon image path inside html/img
    timeout = 4, -- Notification duration in seconds
    
    -- The '_data' table handles advanced routing, sounds, and persistent behaviors
    _data = {
        app = 'bank', -- REQUIRED for persistent lockscreen notifications. Target app (e.g. 'twitter', 'messages')
        
        notification_sound = true, -- Check phone sound settings and play default notification sound
        notification_3D = false,   -- If true, plays the sound as 3D audio emitting from the player
    }
}

exports['cylex_phone']:PhoneNotification(src, data)

--------------------------------------------------------------------------------------

-- Alternative Simple Usage (No advanced _data parameters)
-- PhoneNotification(src, title, text, icon, timeout)
exports['cylex_phone']:PhoneNotification(src, "Title", "Message here", { name = 'app-icon/messages.png' }, 5)
```

#### DoPhoneConfirmation  <a href="#user-content-dophoneconfirmation-server-side" id="user-content-dophoneconfirmation-server-side"></a>

```lua
-- Since this is an interactive UI element, it uses an RPC bridge to communicate 
-- from Server -> Client and wait for the Client's response synchronously.

-- src: number - Player server ID
-- header: string - The header/title of the confirmation
-- text: string - The description/question text
-- data: table - Icon data table

local src = source
local iconData = { name = 'app-icon/settings.png' }

-- Triggers the confirmation on the specified player's phone and waits for their response
local didAccept = RPC.execute('cylex_phone:client:sendConfirmation', src, "Incoming Request", "John Doe wants to join your group. Accept?", iconData)

if didAccept then
    print("Player accepted the request!")
else
    print("Player declined or ignored the request.")
end

```
