Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

NotificationBar

Base type for creating a notification bar to show incoming FelgoMultiplayer push notifications in-game. More...

Import Statement: import Felgo 3.0
Inherits:

Item

Signals

Detailed Description

NotificationBar is the base type for creating a notification bar to show FelgoMultiplayer push notifications.

When a push notification arrives, the FelgoMultiplayer item automatically displays a default notification bar to show the message if the chat view is not opened. After a few seconds, the notification will disappear automatically. Clicking the notification opens the chat view.

Alternatively, you may specify a custom NotificationBar item to replace the default navigation bar and handle notifications on your own.

Note: The notification bar is only displayed if FelgoMultiplayer::handleNotificationInternal is activated, which is the default setting. The FelgoMultiplayer::notificationReceived signal is emitted in every case, so it is possible to still react to notifications on your own.

Set your own NotificationBar implementation for FelgoMultiplayer::notificationBar to replace the default notification bar. Whenever FelgoMultiplayer forwards an incoming notification to be displayed by the NotificationBar, the NotificationBar::display signal is emitted.

Signal Documentation

display(string = message, var = additionalData, bool = isActive)

Whenever FelgoMultiplayer forwards an incoming notification to be displayed by the NotificationBar, this signal is emitted.

The following example uses the signal to disable the default notification bar for chat messages and opens the chat view instead. For friend requests and game invites the notification bar will still be shown.

 FelgoMultiplayer {
   id: multiplayer

   // ...

   // use signal handler to hide notification bar for text messages and jump to chat instead
   Connections {
     target: multiplayer.notificationBar || null
     onDisplay: {
       if(additionalData.type === "text") {
         multiplayer.notificationBar.visible = false
         multiplayer.showChat(additionalData.sender, additionalData.sender_name)
       }
     }
   }
 }

To set a completely custom notification bar instead of the default one, specify your own implementation as the FelgoMultiplayer::notificationBar. Then implement the signal in your custom notification bar to show incoming notifications in the way you want.

The following example shows notifications in a native alert dialog instead of a notification bar (the actual NotificationBar item is never visible in this case):

 GameWindow {
   // ...

   FelgoMultiplayer {
     // ...
     notificationBar: myNotificationBar
   }

   NotificationBar {
     id: myNotificationBar
     onDisplay: {
       nativeUtils.displayMessageBox(additionalData.title, message, 1)
     }
   }
 }

Note: If the multiplayer chat view is opened and can display a notification directly, this signal is not fired. The notification can be consumed and visualized directly in that case. To react on all notifications regardless of the opened view or other FelgoMultiplayer settings, use the FelgoMultiplayer::notificationReceived signal instead.

Note: The corresponding handler is onDisplay.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded