GApplication notification actions with Flatpak

I’m writing a reminder app in python with pygobject, and I’m working on packaging it as a Flatpak. The backend for the app that sends notifications is a seperate app using the Gio.Application class. The notifications use the Gio.Notification class, and are sent through the send_notification method on Gio.Application. The notifications have a button on them but for some reason I can’t activate any app actions when the button is pressed. This issue only happens with Flatpak, and I’m assuming it’s because Gio.Application isn’t exporting the actions over dbus. When I press the button on the notification, the GNOME Shell prints the error ‘Unhandled promise rejection’, and the error is coming from the notfication daemon. Is there a way to export application actions from the flatpak so that GNOME Shell can access them when the notification button is clicked? I have a feeling this might be because I’m using Gio.Application instead of Gtk.Application, but I would rather use Gio.Application because this is just a background service with no windows. Also, I apologize if I’m asking this in the wrong place or if this is a stupid question, I’m new to GTK development.

Exporting actions from flatpaked apps works just fine. You can use the gapplication utility to test this:

flatpak run org.gnome.FileRoller &
gapplication action org.gnome.FileRoller about

Thanks for the response Matthias. I tested this out and the action could be activating using that command. Could the problem be that the application I’m trying to activate actions on is not the main application/command of the flatpak? There is a seperate frontend with a gui that is the main application in the flatpak. The backend is a seperate app that processes dbus calls to create and load reminders and send notifications at the right time. The notifications are being sent by the backend.

Is the backend trying to use the same bus name as the frontend? Probably you need to use a second unique bus name and add --own-name to the flatpak permissions.

According to D-Feet they have different unique names. I also gave them different app ids, and --own-name is in the flatpak manifest. I did a little more testing and found out that gnome-shell is trying to run the actions on the frontend instead of the backend, although I am pretty confident they are being sent from the backend. Do you know what could cause this? If you need me to share more info I can also do that.

Also I can activate the action through D-Feet and it works fine there.

Are you inspecting the traffic with dbus-monitor to verify the application ids are matching? It is possible gnome-shell may be trying to look up a .desktop file with the id matching the flatpak app. (See notificationDaemon.js)

If nothing else works, it may be necessary to proxy the actions through to the backend from the frontend.

That’s what I ended up doing. Looked through the glib and xdg desktop portal source code and it looks like Gio.send_notification just uses the flatpak id and theres nothing you can do about it.

That makes sense for the portal to enforce that, because otherwise flatpak apps could spoof the id of an external app.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.