NSUserNotificationCenter not showing notifications












1















I'm not sure if I got something wrong but from the examples I could find. I wrote that little helloworld.



#import <Foundation/Foundation.h>
#import <Foundation/NSUserNotification.h>


int main (int argc, const char * argv)
{
NSUserNotification *userNotification = [[NSUserNotification alloc] init];
userNotification.title = @"Some title";
userNotification.informativeText = @"Some text";

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];

return 0;
}


I compile it with:



cc -framework Foundation -o app main.m


It compiles and I can execute it but it won't show anything. For some reasons, nothing gets presented. I read that Notifications may not get displayed if the application is the main actor. How can I make it show Notification?










share|improve this question



























    1















    I'm not sure if I got something wrong but from the examples I could find. I wrote that little helloworld.



    #import <Foundation/Foundation.h>
    #import <Foundation/NSUserNotification.h>


    int main (int argc, const char * argv)
    {
    NSUserNotification *userNotification = [[NSUserNotification alloc] init];
    userNotification.title = @"Some title";
    userNotification.informativeText = @"Some text";

    [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];

    return 0;
    }


    I compile it with:



    cc -framework Foundation -o app main.m


    It compiles and I can execute it but it won't show anything. For some reasons, nothing gets presented. I read that Notifications may not get displayed if the application is the main actor. How can I make it show Notification?










    share|improve this question

























      1












      1








      1








      I'm not sure if I got something wrong but from the examples I could find. I wrote that little helloworld.



      #import <Foundation/Foundation.h>
      #import <Foundation/NSUserNotification.h>


      int main (int argc, const char * argv)
      {
      NSUserNotification *userNotification = [[NSUserNotification alloc] init];
      userNotification.title = @"Some title";
      userNotification.informativeText = @"Some text";

      [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];

      return 0;
      }


      I compile it with:



      cc -framework Foundation -o app main.m


      It compiles and I can execute it but it won't show anything. For some reasons, nothing gets presented. I read that Notifications may not get displayed if the application is the main actor. How can I make it show Notification?










      share|improve this question














      I'm not sure if I got something wrong but from the examples I could find. I wrote that little helloworld.



      #import <Foundation/Foundation.h>
      #import <Foundation/NSUserNotification.h>


      int main (int argc, const char * argv)
      {
      NSUserNotification *userNotification = [[NSUserNotification alloc] init];
      userNotification.title = @"Some title";
      userNotification.informativeText = @"Some text";

      [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];

      return 0;
      }


      I compile it with:



      cc -framework Foundation -o app main.m


      It compiles and I can execute it but it won't show anything. For some reasons, nothing gets presented. I read that Notifications may not get displayed if the application is the main actor. How can I make it show Notification?







      nsusernotification nsusernotificationcenter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 9 '13 at 7:55









      Loïc Faure-LacroixLoïc Faure-Lacroix

      9,27954683




      9,27954683
























          4 Answers
          4






          active

          oldest

          votes


















          7














          set a delegate and override



          - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
          shouldPresentNotification:(NSUserNotification *)notification {
          return YES;
          }





          share|improve this answer


























          • could you add a complete sample, i'm not sure to understand where to put that line.

            – Loïc Faure-Lacroix
            May 19 '13 at 9:10











          • Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

            – Ants
            Jun 26 '13 at 2:48











          • @Ants how to set delegate in python

            – imp
            Nov 18 '13 at 4:42



















          1














          For a complete example in Objective-C and Swift:



          We need to provide a NSUserNotificationCenterDelegate, in the simplest case we can use AppDelegate for this



          Objective-C



          We need to modify AppDelegate provide NSUserNotificationCenterDelegate method. From a clean AppDelegate (which looks like this...)



          @interface AppDelegate ()


          We'd modify it to be:



          @interface AppDelegate () <NSUserNotificationCenterDelegate>


          Now we can provide the required delegate method inside @implementation AppDelegate



          - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
          shouldPresentNotification:(NSUserNotification *)notification {
          return YES;
          }


          Swift 4



          You can use an extension of AppDelegate to provide NSUserNotificationCenterDelegate methods:



          extension AppDelegate: NSUserNotificationCenterDelegate {
          func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
          return true
          }
          }





          share|improve this answer































            0














            I know it's an old question - but as there may be people looking for an answer how to do this in Python & PyObjC I will post the correct syntax here (as it's one of the top google results). As I can't comment on imp's comment I will post this as another answer.



            It's possible to do the same in Python with pyobjc this way:



            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
            return True


            Full class would look like this:



            from Cocoa import NSObject
            import objc

            class MountainLionNotification(NSObject):
            """ MacOS Notifications """
            # Based on http://stackoverflow.com/questions/12202983/working-with-mountain-lions-notification-center-using-pyobjc

            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
            return True

            def init(self):

            self = super(MountainLionNotification, self).init()
            if self is None: return None

            # Get objc references to the classes we need.
            self.NSUserNotification = objc.lookUpClass('NSUserNotification')
            self.NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')

            return self

            def clearNotifications(self):
            """Clear any displayed alerts we have posted. Requires Mavericks."""

            NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
            NSUserNotificationCenter.defaultUserNotificationCenter().removeAllDeliveredNotifications()

            def notify(self, title="", subtitle="", text="", url=""):
            """Create a user notification and display it."""

            notification = self.NSUserNotification.alloc().init()
            notification.setTitle_(str(title))
            notification.setSubtitle_(str(subtitle))
            notification.setInformativeText_(str(text))
            # notification.setSoundName_("NSUserNotificationDefaultSoundName")
            notification.setHasActionButton_(False)
            notification.setActionButtonTitle_("View")
            # notification.setUserInfo_({"action":"open_url", "value": url})

            self.NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
            self.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)

            # Note that the notification center saves a *copy* of our object.
            return notification





            share|improve this answer

































              0














              Be sure to assign a new identifier for any new notification. A notification will only show once, unless a new identifier is used or the user clears their notification history.






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15896348%2fnsusernotificationcenter-not-showing-notifications%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                7














                set a delegate and override



                - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                shouldPresentNotification:(NSUserNotification *)notification {
                return YES;
                }





                share|improve this answer


























                • could you add a complete sample, i'm not sure to understand where to put that line.

                  – Loïc Faure-Lacroix
                  May 19 '13 at 9:10











                • Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                  – Ants
                  Jun 26 '13 at 2:48











                • @Ants how to set delegate in python

                  – imp
                  Nov 18 '13 at 4:42
















                7














                set a delegate and override



                - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                shouldPresentNotification:(NSUserNotification *)notification {
                return YES;
                }





                share|improve this answer


























                • could you add a complete sample, i'm not sure to understand where to put that line.

                  – Loïc Faure-Lacroix
                  May 19 '13 at 9:10











                • Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                  – Ants
                  Jun 26 '13 at 2:48











                • @Ants how to set delegate in python

                  – imp
                  Nov 18 '13 at 4:42














                7












                7








                7







                set a delegate and override



                - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                shouldPresentNotification:(NSUserNotification *)notification {
                return YES;
                }





                share|improve this answer















                set a delegate and override



                - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                shouldPresentNotification:(NSUserNotification *)notification {
                return YES;
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 11 '18 at 0:51









                ocodo

                21.7k1481107




                21.7k1481107










                answered May 6 '13 at 12:06









                lxDriverlxDriver

                711




                711













                • could you add a complete sample, i'm not sure to understand where to put that line.

                  – Loïc Faure-Lacroix
                  May 19 '13 at 9:10











                • Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                  – Ants
                  Jun 26 '13 at 2:48











                • @Ants how to set delegate in python

                  – imp
                  Nov 18 '13 at 4:42



















                • could you add a complete sample, i'm not sure to understand where to put that line.

                  – Loïc Faure-Lacroix
                  May 19 '13 at 9:10











                • Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                  – Ants
                  Jun 26 '13 at 2:48











                • @Ants how to set delegate in python

                  – imp
                  Nov 18 '13 at 4:42

















                could you add a complete sample, i'm not sure to understand where to put that line.

                – Loïc Faure-Lacroix
                May 19 '13 at 9:10





                could you add a complete sample, i'm not sure to understand where to put that line.

                – Loïc Faure-Lacroix
                May 19 '13 at 9:10













                Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                – Ants
                Jun 26 '13 at 2:48





                Great thanks for this. It's interesting that if you do not set the delegate and implement this method, the notification is visible in Notification Center, but does not get displayed.

                – Ants
                Jun 26 '13 at 2:48













                @Ants how to set delegate in python

                – imp
                Nov 18 '13 at 4:42





                @Ants how to set delegate in python

                – imp
                Nov 18 '13 at 4:42













                1














                For a complete example in Objective-C and Swift:



                We need to provide a NSUserNotificationCenterDelegate, in the simplest case we can use AppDelegate for this



                Objective-C



                We need to modify AppDelegate provide NSUserNotificationCenterDelegate method. From a clean AppDelegate (which looks like this...)



                @interface AppDelegate ()


                We'd modify it to be:



                @interface AppDelegate () <NSUserNotificationCenterDelegate>


                Now we can provide the required delegate method inside @implementation AppDelegate



                - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                shouldPresentNotification:(NSUserNotification *)notification {
                return YES;
                }


                Swift 4



                You can use an extension of AppDelegate to provide NSUserNotificationCenterDelegate methods:



                extension AppDelegate: NSUserNotificationCenterDelegate {
                func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
                return true
                }
                }





                share|improve this answer




























                  1














                  For a complete example in Objective-C and Swift:



                  We need to provide a NSUserNotificationCenterDelegate, in the simplest case we can use AppDelegate for this



                  Objective-C



                  We need to modify AppDelegate provide NSUserNotificationCenterDelegate method. From a clean AppDelegate (which looks like this...)



                  @interface AppDelegate ()


                  We'd modify it to be:



                  @interface AppDelegate () <NSUserNotificationCenterDelegate>


                  Now we can provide the required delegate method inside @implementation AppDelegate



                  - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                  shouldPresentNotification:(NSUserNotification *)notification {
                  return YES;
                  }


                  Swift 4



                  You can use an extension of AppDelegate to provide NSUserNotificationCenterDelegate methods:



                  extension AppDelegate: NSUserNotificationCenterDelegate {
                  func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
                  return true
                  }
                  }





                  share|improve this answer


























                    1












                    1








                    1







                    For a complete example in Objective-C and Swift:



                    We need to provide a NSUserNotificationCenterDelegate, in the simplest case we can use AppDelegate for this



                    Objective-C



                    We need to modify AppDelegate provide NSUserNotificationCenterDelegate method. From a clean AppDelegate (which looks like this...)



                    @interface AppDelegate ()


                    We'd modify it to be:



                    @interface AppDelegate () <NSUserNotificationCenterDelegate>


                    Now we can provide the required delegate method inside @implementation AppDelegate



                    - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                    shouldPresentNotification:(NSUserNotification *)notification {
                    return YES;
                    }


                    Swift 4



                    You can use an extension of AppDelegate to provide NSUserNotificationCenterDelegate methods:



                    extension AppDelegate: NSUserNotificationCenterDelegate {
                    func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
                    return true
                    }
                    }





                    share|improve this answer













                    For a complete example in Objective-C and Swift:



                    We need to provide a NSUserNotificationCenterDelegate, in the simplest case we can use AppDelegate for this



                    Objective-C



                    We need to modify AppDelegate provide NSUserNotificationCenterDelegate method. From a clean AppDelegate (which looks like this...)



                    @interface AppDelegate ()


                    We'd modify it to be:



                    @interface AppDelegate () <NSUserNotificationCenterDelegate>


                    Now we can provide the required delegate method inside @implementation AppDelegate



                    - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 
                    shouldPresentNotification:(NSUserNotification *)notification {
                    return YES;
                    }


                    Swift 4



                    You can use an extension of AppDelegate to provide NSUserNotificationCenterDelegate methods:



                    extension AppDelegate: NSUserNotificationCenterDelegate {
                    func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
                    return true
                    }
                    }






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 11 '18 at 2:14









                    ocodoocodo

                    21.7k1481107




                    21.7k1481107























                        0














                        I know it's an old question - but as there may be people looking for an answer how to do this in Python & PyObjC I will post the correct syntax here (as it's one of the top google results). As I can't comment on imp's comment I will post this as another answer.



                        It's possible to do the same in Python with pyobjc this way:



                        def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                        return True


                        Full class would look like this:



                        from Cocoa import NSObject
                        import objc

                        class MountainLionNotification(NSObject):
                        """ MacOS Notifications """
                        # Based on http://stackoverflow.com/questions/12202983/working-with-mountain-lions-notification-center-using-pyobjc

                        def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                        return True

                        def init(self):

                        self = super(MountainLionNotification, self).init()
                        if self is None: return None

                        # Get objc references to the classes we need.
                        self.NSUserNotification = objc.lookUpClass('NSUserNotification')
                        self.NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')

                        return self

                        def clearNotifications(self):
                        """Clear any displayed alerts we have posted. Requires Mavericks."""

                        NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
                        NSUserNotificationCenter.defaultUserNotificationCenter().removeAllDeliveredNotifications()

                        def notify(self, title="", subtitle="", text="", url=""):
                        """Create a user notification and display it."""

                        notification = self.NSUserNotification.alloc().init()
                        notification.setTitle_(str(title))
                        notification.setSubtitle_(str(subtitle))
                        notification.setInformativeText_(str(text))
                        # notification.setSoundName_("NSUserNotificationDefaultSoundName")
                        notification.setHasActionButton_(False)
                        notification.setActionButtonTitle_("View")
                        # notification.setUserInfo_({"action":"open_url", "value": url})

                        self.NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
                        self.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)

                        # Note that the notification center saves a *copy* of our object.
                        return notification





                        share|improve this answer






























                          0














                          I know it's an old question - but as there may be people looking for an answer how to do this in Python & PyObjC I will post the correct syntax here (as it's one of the top google results). As I can't comment on imp's comment I will post this as another answer.



                          It's possible to do the same in Python with pyobjc this way:



                          def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                          return True


                          Full class would look like this:



                          from Cocoa import NSObject
                          import objc

                          class MountainLionNotification(NSObject):
                          """ MacOS Notifications """
                          # Based on http://stackoverflow.com/questions/12202983/working-with-mountain-lions-notification-center-using-pyobjc

                          def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                          return True

                          def init(self):

                          self = super(MountainLionNotification, self).init()
                          if self is None: return None

                          # Get objc references to the classes we need.
                          self.NSUserNotification = objc.lookUpClass('NSUserNotification')
                          self.NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')

                          return self

                          def clearNotifications(self):
                          """Clear any displayed alerts we have posted. Requires Mavericks."""

                          NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
                          NSUserNotificationCenter.defaultUserNotificationCenter().removeAllDeliveredNotifications()

                          def notify(self, title="", subtitle="", text="", url=""):
                          """Create a user notification and display it."""

                          notification = self.NSUserNotification.alloc().init()
                          notification.setTitle_(str(title))
                          notification.setSubtitle_(str(subtitle))
                          notification.setInformativeText_(str(text))
                          # notification.setSoundName_("NSUserNotificationDefaultSoundName")
                          notification.setHasActionButton_(False)
                          notification.setActionButtonTitle_("View")
                          # notification.setUserInfo_({"action":"open_url", "value": url})

                          self.NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
                          self.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)

                          # Note that the notification center saves a *copy* of our object.
                          return notification





                          share|improve this answer




























                            0












                            0








                            0







                            I know it's an old question - but as there may be people looking for an answer how to do this in Python & PyObjC I will post the correct syntax here (as it's one of the top google results). As I can't comment on imp's comment I will post this as another answer.



                            It's possible to do the same in Python with pyobjc this way:



                            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                            return True


                            Full class would look like this:



                            from Cocoa import NSObject
                            import objc

                            class MountainLionNotification(NSObject):
                            """ MacOS Notifications """
                            # Based on http://stackoverflow.com/questions/12202983/working-with-mountain-lions-notification-center-using-pyobjc

                            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                            return True

                            def init(self):

                            self = super(MountainLionNotification, self).init()
                            if self is None: return None

                            # Get objc references to the classes we need.
                            self.NSUserNotification = objc.lookUpClass('NSUserNotification')
                            self.NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')

                            return self

                            def clearNotifications(self):
                            """Clear any displayed alerts we have posted. Requires Mavericks."""

                            NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
                            NSUserNotificationCenter.defaultUserNotificationCenter().removeAllDeliveredNotifications()

                            def notify(self, title="", subtitle="", text="", url=""):
                            """Create a user notification and display it."""

                            notification = self.NSUserNotification.alloc().init()
                            notification.setTitle_(str(title))
                            notification.setSubtitle_(str(subtitle))
                            notification.setInformativeText_(str(text))
                            # notification.setSoundName_("NSUserNotificationDefaultSoundName")
                            notification.setHasActionButton_(False)
                            notification.setActionButtonTitle_("View")
                            # notification.setUserInfo_({"action":"open_url", "value": url})

                            self.NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
                            self.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)

                            # Note that the notification center saves a *copy* of our object.
                            return notification





                            share|improve this answer















                            I know it's an old question - but as there may be people looking for an answer how to do this in Python & PyObjC I will post the correct syntax here (as it's one of the top google results). As I can't comment on imp's comment I will post this as another answer.



                            It's possible to do the same in Python with pyobjc this way:



                            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                            return True


                            Full class would look like this:



                            from Cocoa import NSObject
                            import objc

                            class MountainLionNotification(NSObject):
                            """ MacOS Notifications """
                            # Based on http://stackoverflow.com/questions/12202983/working-with-mountain-lions-notification-center-using-pyobjc

                            def userNotificationCenter_shouldPresentNotification_(self, center, notification):
                            return True

                            def init(self):

                            self = super(MountainLionNotification, self).init()
                            if self is None: return None

                            # Get objc references to the classes we need.
                            self.NSUserNotification = objc.lookUpClass('NSUserNotification')
                            self.NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')

                            return self

                            def clearNotifications(self):
                            """Clear any displayed alerts we have posted. Requires Mavericks."""

                            NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
                            NSUserNotificationCenter.defaultUserNotificationCenter().removeAllDeliveredNotifications()

                            def notify(self, title="", subtitle="", text="", url=""):
                            """Create a user notification and display it."""

                            notification = self.NSUserNotification.alloc().init()
                            notification.setTitle_(str(title))
                            notification.setSubtitle_(str(subtitle))
                            notification.setInformativeText_(str(text))
                            # notification.setSoundName_("NSUserNotificationDefaultSoundName")
                            notification.setHasActionButton_(False)
                            notification.setActionButtonTitle_("View")
                            # notification.setUserInfo_({"action":"open_url", "value": url})

                            self.NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
                            self.NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)

                            # Note that the notification center saves a *copy* of our object.
                            return notification






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Aug 8 '16 at 8:03









                            Pylinux

                            6,07414346




                            6,07414346










                            answered May 28 '15 at 15:07









                            Sebastian TänzerSebastian Tänzer

                            214




                            214























                                0














                                Be sure to assign a new identifier for any new notification. A notification will only show once, unless a new identifier is used or the user clears their notification history.






                                share|improve this answer




























                                  0














                                  Be sure to assign a new identifier for any new notification. A notification will only show once, unless a new identifier is used or the user clears their notification history.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    Be sure to assign a new identifier for any new notification. A notification will only show once, unless a new identifier is used or the user clears their notification history.






                                    share|improve this answer













                                    Be sure to assign a new identifier for any new notification. A notification will only show once, unless a new identifier is used or the user clears their notification history.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 24 '18 at 0:23









                                    BerikBerik

                                    6,79322335




                                    6,79322335






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15896348%2fnsusernotificationcenter-not-showing-notifications%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        404 Error Contact Form 7 ajax form submitting

                                        How to know if a Active Directory user can login interactively

                                        TypeError: fit_transform() missing 1 required positional argument: 'X'