-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flutter_local_notifications_linux] Add support for org.freedesktop.portal.Notification #1757
Comments
Support for this would require a PR as Linux support came from a PR from @proninyaroslav so you would need to submit a PR for it. In saying that, I'm not even sure if a PR would be appropriate. Perhaps this is due to my limited knowledge of Linux (note: I don't work with the platform/OS) but even Canonical's own package for notifications uses |
Is |
While the desktop portals started as an interface specifically for Flatpak, they appear to have been adopted and supported much more widely now. It looks as though the Notification portal has been available since the initial 0.1 release of xdg-desktop-portal. xdg-desktop-portal is supported at least as far back as: So I think it is safe to say it has wide and time-tested adoption. I tried running the specification through the dbus generator: // This file was generated using the following command and may be overwritten.
// dart-dbus generate-remote-object org.freedesktop.portal.Notification.xml
import 'package:dbus/dbus.dart';
/// Signal data for org.freedesktop.portal.Notification.ActionInvoked.
class OrgFreedesktopPortalNotificationActionInvoked extends DBusSignal {
String get id => values[0].asString();
String get action => values[1].asString();
List<DBusValue> get parameter => values[2].asVariantArray().toList();
OrgFreedesktopPortalNotificationActionInvoked(DBusSignal signal) : super(sender: signal.sender, path: signal.path, interface: signal.interface, name: signal.name, values: signal.values);
}
class OrgFreedesktopPortalNotification extends DBusRemoteObject {
/// Stream of org.freedesktop.portal.Notification.ActionInvoked signals.
late final Stream<OrgFreedesktopPortalNotificationActionInvoked> actionInvoked;
OrgFreedesktopPortalNotification(DBusClient client, String destination, {DBusObjectPath path = const DBusObjectPath.unchecked('/')}) : super(client, name: destination, path: path) {
actionInvoked = DBusRemoteObjectSignalStream(object: this, interface: 'org.freedesktop.portal.Notification', name: 'ActionInvoked', signature: DBusSignature('ssav')).asBroadcastStream().map((signal) => OrgFreedesktopPortalNotificationActionInvoked(signal));
}
/// Gets org.freedesktop.portal.Notification.version
Future<int> getversion() async {
var value = await getProperty('org.freedesktop.portal.Notification', 'version', signature: DBusSignature('u'));
return value.asUint32();
}
/// Invokes org.freedesktop.portal.Notification.AddNotification()
Future<void> callAddNotification(String id, Map<String, DBusValue> notification, {bool noAutoStart = false, bool allowInteractiveAuthorization = false}) async {
await callMethod('org.freedesktop.portal.Notification', 'AddNotification', [DBusString(id), DBusDict.stringVariant(notification)], replySignature: DBusSignature(''), noAutoStart: noAutoStart, allowInteractiveAuthorization: allowInteractiveAuthorization);
}
/// Invokes org.freedesktop.portal.Notification.RemoveNotification()
Future<void> callRemoveNotification(String id, {bool noAutoStart = false, bool allowInteractiveAuthorization = false}) async {
await callMethod('org.freedesktop.portal.Notification', 'RemoveNotification', [DBusString(id)], replySignature: DBusSignature(''), noAutoStart: noAutoStart, allowInteractiveAuthorization: allowInteractiveAuthorization);
}
} I tested it only briefly, but it seems to work well even outside of Flatpak confines: late OrgFreedesktopPortalNotification notificationPortal;
Future<void> main() async {
final client = DBusClient.session();
notificationPortal = OrgFreedesktopPortalNotification(
client,
'org.freedesktop.portal.Desktop',
path: DBusObjectPath('/org/freedesktop/portal/desktop'),
);
// Add a notification
await addNotification(
'app_name',
{
'title': DBusString('Test Title'),
'body': DBusString('Test Body'),
},
);
// Close the client
await client.close();
}
// AddNotification
Future<void> addNotification(
String id,
Map<String, DBusValue> notification,
) async {
await notificationPortal.callAddNotification(
id,
notification,
);
} Seems like since it works basically everywhere and is a modern notifications API on Linux it would be good to transition to. Thoughts? :) |
My knowledge of Linux is limited so with what I know and if it doesn't cause breaking changes or limit supported Linux versions that those who were using the plugin before end up not being able to do so then that sounds reasonable to me |
The xdg-desktop-portal is the new standard for desktop notifications and is supported by GNOME, KDE, and other desktop environments. It also works with Flatpak and Snap applications. Resolves MaikuB#1757
The xdg-desktop-portal is the new standard for desktop notifications and is supported by GNOME, KDE, and other desktop environments. It also works with Flatpak and Snap applications. Resolves MaikuB#1757
The xdg-desktop-portal is the new standard for desktop notifications and is supported by GNOME, KDE, and other desktop environments. It also works with Flatpak and Snap applications. Resolves MaikuB#1757
The xdg-desktop-portal is the new standard for desktop notifications and is supported by GNOME, KDE, and other desktop environments. It also works with Flatpak and Snap applications. Resolves MaikuB#1757
The xdg-desktop-portal is the new standard for desktop notifications and is supported by GNOME, KDE, and other desktop environments. It also works with Flatpak and Snap applications. Resolves MaikuB#1757
Inside a Flatpak sandbox,
org.freedesktop.Notifications
is not available. Sandboxed apps are supposed to talk toorg.freedesktop.portal.Notification
instead.https://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-org.freedesktop.portal.Notification
The text was updated successfully, but these errors were encountered: