Why does my notification never appear?

Here's what I'm trying.

    // Ubuntu 20.04, fully updated
    // g++ -o Recipes Recipes.cc `pkg-config gtkmm-3.0 --cflags --libs`
    
    #include <gtkmm.h>
    
    class Recipes : public Gtk::Application
    {
    public:
        static Glib::RefPtr<Recipes > create ();
    protected:
        Recipes ();
    };
    
    Glib::RefPtr<Recipes > Recipes::create ()
    {
        return ( Glib::RefPtr<Recipes > ( new Recipes () ) );
    }
    
    Recipes::Recipes ()
      : Gtk::Application ( "org.pwolff.recipes" )
    {
        register_application ();
        Glib::RefPtr<Gio::Notification > refNote = Gio::Notification::create ( "recipe" );
        refNote->set_body ( "Chipotle Shrimp" );
        refNote->set_priority ( Gio::NOTIFICATION_PRIORITY_URGENT );
        send_notification ( "recipe", refNote );
    }
    
    int main ( int argc, char *argv[] )
    {
        Glib::RefPtr<Recipes > refApp = Recipes::create ();
        const int status = refApp->run ( argc, argv );
        return ( status );
    }

The notification never appears. Am I missing something? Or perhaps this is an instance covered by the disclaimer in the documentation: "There is no guarantee that the notification is displayed immediately, or even at all."


Solution 1:

First install the required dependencies

sudo apt install build-essential libgtkmm-3.0-dev

Now compile the program

g++ Recipes.cc `pkg-config gtkmm-3.0 --cflags --libs` -o Recipes

Now run the program

./Recipes

enter image description here Works for me in Xubuntu 20.04 and also in Cinnamon running in Ubuntu 20.04, but does not work in gnomes hell.