omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    notification module - API

    Pythonista
    api notification
    3
    7
    6247
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      @omz, I am not sure if the implementation of the notification module is a pure reflection of the objc lib or not. But it seems to me that it would be nice if notification.schedule supported a datetime object either tz aware or naive datetime rather than just a delay.

      Also for the notification.cancel method, it would seem like a reference str would be better than having to pass back the dict that notification.schedule returns. meaning that notification.schedule could return something like a str(uuid.uuid4()) in the dict that you could store to be able to cancel the notification in the future. This would be a lot easier to save/retrieve.

      I am just doing some stuff with timers at the moment. And then you think about setting notifications along with your timer, then for me I see the api does not really line up well, at least for my case.

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        The notification module is due for an overhaul, I agree. There are also some new system capabilities it doesn’t take advantage of (attachments and interactive notifications).

        Phuket2 1 Reply Last reply Reply Quote 3
        • mikael
          mikael last edited by

          While we are on the topic, I was just trying to do something with it today and noticed that providing an empty string as sound still played a default sound when the notification triggered.

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            @mikael That's intentional – if you want no sound at all, pass sound_name=None (or leave out that argument).

            mikael 1 Reply Last reply Reply Quote 0
            • mikael
              mikael @omz last edited by mikael

              @omz, okay, thanks. Then it is an issue with the docs, which state: ”Use an empty string to schedule a silent notification.”

              I created an issue as a reminder.

              1 Reply Last reply Reply Quote 0
              • Phuket2
                Phuket2 @omz last edited by

                @omz, I know above you say the notification module needs some work. But you seem to be talking about new features.

                I have been doing a little more today and realised a few things.

                1. After setting my notications, If I am not in Pythonista, I dont get the notification or sound on the screen, but it is added to the list of notifications if you pull down from the top of the screen.
                2. If you are in Pythonista when the notification occurs, you get a dialog with the msg and sound, but its not added to the list of notifications that have occurred in the notifications list.

                I am not sure, but I have a feeling in the past so time ago that notifications did show up correctly in other apps (I could be wrong about that).

                I have put a pic of my iOS notifications below. Also a basic example of the code. It's not the code I want to use, but it acts as an example of it.

                So I am asking is this behaviour correct for Pythonista? Or is this part of needs to be addressed in the notifications module.

                I have tried to implement my game timers many ways. But I have so many and they vary so often. I have a feeling that the notications module would be a good way to deal with this. But I need the notifications to follow the iOS settings before its would be useful in this context.

                import notification
                
                '''
                Simple example to show setting a notification in a loop each minute
                for x mins.
                
                In my real implementation I am using Arrow.span.
                For example, I would like to set notifications for:
                    from (a local time) every 1 hour with a message
                    from (a local time) every 3 hours with a message
                    from (a local time) every 24 hours with a message
                    etc... With a repeat/duration I set.
                
                I can set this up and do it using arrow correctly. But the behaviour of the
                notifications module makes it unsuable for this senerio.
                '''
                
                num_mins = 5
                delays = [60 * (i + 1) for i in range(num_mins)]
                
                for i, d in enumerate(delays):
                    x = notification.schedule('Your Game Notification, Mins={}'.format(i + 1),
                                              delay=d,
                                              sound_name='arcade:Powerup_1',
                                              action_url=None)
                
                # A notification so you know this msg group is finished
                x = notification.schedule('Game Nofications are over!!!',
                                          delay=delays[num_mins - 1] + 10,
                                          sound_name='arcade:Powerup_3',
                                          action_url=None)
                
                # just put this here in testing so you aviod running multiple times
                print('Finished Running')
                

                1 Reply Last reply Reply Quote 0
                • Phuket2
                  Phuket2 last edited by

                  Hmmm, live and Learn. Sorry @omz, my mistake. I have dnd(do not disturb) on. If that is turned off then the notications are working as expected. Works very good

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors