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

Forums

OverviewFelgo 2 Support (Qt 5) › Notification plugin not working as expected

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24655

    Allan

    Hello,

     

    I’m trying to use the Local Notification plugin.

    My goal is to fire a notification when the app is closing and on special event.

     

    I used the example project. It’s only working as expected only when the notification is triggered and the app is paused.

    When the app is running the notification is triggered (proof is onNotificationFired) but not showing.

    Maybe when the app is running the notification is dismissed immediately. (not so much a problem for our use case, we can show some popin…)

     

    The real problem is when i schedule a notification (interval 20 sec) and close the app, the notification is not appearing.

     

    Is that normal behavior ? How can I trigger a notification some seconds after closing my app ?

     

    Thanks.

    #24657

    Alex
    Felgo Team

    Hi Allan,

    it is intended that there is no notification bubble while the app is open, a notification is primarily intended to bring a user back to the app. If you still want to notify the user while the app is already open, you can react to the notificationFired signal to show some custom notification.

    Regarding scheduling while closing the app, first of all, make sure that this is really the best approach for your use-case. On mobile this may not always be 100% under your control. For example, if the app is already in the background, and the operating system decides to shut it down to e.g. free up resources, it will do so without the user or the application noticing it. The only thing that is really fully controlable is when an app is going to the background (applicationPaused signal).

    If you still want to shedule a notification in the case of the user actively closing the application, the onClosing signal of the App is effectively too late for this complex operation. But there is another signal (from Qt.application) that you can connect to, which is fired earlier and should allow this operation to complete. I am not sure if it is guaranteed to work in 100% of the cases though, so again your application should not completely rely on this. Here is an example that you can try:

    import QtQuick 2.8
    import Felgo 3.0
    
    App {
    
      Connections {
        target: Qt.application
        enabled: true // In case you want to disable this in certain cases, use this property
        function onAboutToQuit() {
          notificationManager.scheduleNotification(staticNotification)
        }
      }
    
      NotificationManager {
        id: notificationManager
    
        onNotificationFired: {
          console.debug("Notification with id " + notificationId + " fired")
        }
      }
    
      Notification {
        id: staticNotification
        notificationId: "static_notification"
        message: "I'm statically defined in the app"
        timeInterval: 5
      }
    
      NavigationStack {
        Page {
          id: page
          title: "Local Notification"
          Column {
            anchors.centerIn: parent
    
            AppButton {
              text: "Static Notification (interval)"
              onClicked: {
                // Trigger notification in 5 seconds
                notificationManager.scheduleNotification(staticNotification)
              }
            }
          }
        }// Page
      } // NavigationStack
    }// App
    

    Best,
    Alex

    #24658

    Allan

    Hi,

    Thanks for all the information.
    I will test that, but in fact i don’t think that’s the best idea for our use case.

    I’ll come back here if I need something else.

    Thanks for your time.

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded