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 cancel bug?

    Pythonista
    5
    8
    3718
    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.
    • JonB
      JonB last edited by

      Cancel_all works ok, but cancel doesn't seem to work:

      import notification
      n=notification.get_scheduled()
      print 'initial num notifications:', len(n)
      
      notification.schedule('test',120)
      n=notification.get_scheduled()
      print 'added one: ', len(n)
      
      notification.cancel(n[0])
      n=notification.get_scheduled()
      print 'after cancel', len(n)
      

      The result:

      initial num notifications: 3
      added one:  4
      after cancel 4
      
      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Thanks, I'll look into it.

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

          A delay after cancel helps, e.g. time.sleep(1) works on my iPad version 3.

          Good luck!

          Cherubjk

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

            Well, I have two notifications that simply won't delete, it has been a few days!

            In case it matters, the two have the same message and action, no sound, slightly different fire times. Here's the result of get_scheduled. I was trying to prune notifications of the same name. I think it must sometimes work, otherwise I'd probably have more of these.

             [{u'action_url': u'pythonista://renewbooks?action=run', u'sound_name': u'', 
             u'message': u'renew books', u'fire_date':1396594740.000119}, 
             {u'action_url': u'pythonista://renewbooks?action=run', u'sound_name': u'', 
             u'message': u'renew books', u'fire_date': 1396594740.000122}]
            

            Also... In the code above, I have found that if you store the result of schedule(), you are able to cancel it. But when schedule is called without outputs, no go.
            I'm running ios 7.1, ipad 2.

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

              Original code works fine for me.

              IPhone 5s, ios 7.1

              initial num notifications: 0
              added one:  1
              after cancel 0
              
              1 Reply Last reply Reply Quote 0
              • ccc
                ccc last edited by

                Try creating several notifications and then see if you can replicate the problem.

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

                  It is strange, sometimes it works, sometimes it doesn't.
                  What seems to reliably fail... Create a notification. Then, kill the app.
                  Then, launch again and try to cancel the notification.

                  I think this may also happen when the task gets killed in the background when memory runs low.

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

                    I made a couple more tests.

                    I have put your code, JonB, into a loop except the initialization. Then I checked under what conditions the cancellation fails. Comparison of the fire date in the return value of notification.schedule with the corresponding value in the last element returned by notification.get_scheduled showed a tiny difference in every case of failure, and no difference in all cases of success.

                    Managing the results of notification.schedule in an own list and using these elements for cancellation always works.

                    I guess this cannot be circumvented in a script.

                    @omz: Fantastic app though!

                    Chears

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