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