What is the semantics of notification.set_badge()
It is mentioned in the release notes but not the documentation.
omz last edited by
You can pass an integer to set the app's badge number (the red bubble that usually indicates unread counts etc.). If you pass zero, the badge is removed.
import notification notification.set_badge(123) print 'Badge updated, press home button to view ;)'
To be honest, I don't see a ton of use cases for this.
Thanks. I'm writing an app to remind me to do various measurement tasks (for example measure my blood sugar) at various times and record the results with the time. The scheduling would be handled with notifications. I want to incorporate the ability to 'snooze', i.e. (reschedule) the task. I would use the badge to see at a glance whether I have postponed tasks. I haven't see an app with the combination of remind, require and record a value plus optional snooze so I'm writing my own. Badges are just a bonus but a nice one. It is nice to be able to do it all in Python. ui was the last missing piece. Thanks ;-)
I'll be adding tasks like "remember to take my meds" where the recorded data is just the time. I'll probably store the data on dropbox where it can be shared with apps on my desktop as well add an export capability that will generate a csv file. The export would be either to dropbox or email. I might add the ability to plot data. All things supported by existing python modules.
It would be really nice if some future version of pythonista allowed us to run code as part of a notification, or scheduled background task, whatever. I'm sure I have other apps that do background processing to send me a notification or badge... Like mail checking apps, etc. There are lots of use cases for badges if they can be set in the background.
Or, if there was an option in the notification module to automatically increment the badge counter when thr notification time hits. Maybe a dict of badge keys, and the notification would take a key and in increment the count for a specific key.... Then pythonista would auto display the sum of counts for all keys.
Alternatively, notifications should have an optional re-notification time if not acted upon...basically a snooze timer, so that it will keep bugging me until I respond. Technically I could do this by setting multiple notifications originally, but since the mechanisms for looking up notifications are somewhat crude, it would be difficult to find which notifications need to be deleted.
One thing that limits the usefulness of notifications in pythonista is that if you ignore the notification, it will never remind you again. I have a script I use that renews my library books, and sets notifications before my next books are due. But if I end up getting overdue fines often because I didn't click the notification right away, then forget about it. Badges or renotification would make this feature much more useful.
I have a script that checks my library account to see when books are due, then sets notifications a few days before they are do. Then when I click e notification, it logs in and renews the books. But, the problem with notifications is that, if you don't respond immediately, the notification gets buried, and you might forget to check it again.
I was thinking of labeling the notifications in the url, as an extra argument or list of arguments. That would make it easier to schedule and find a set of notifications. Interesting that you are having the same issue. Notifications should clearly have some kind of snooze. I'm a bit baffled that the idea isn't more popular. I got addicted to the idea in Outlook. In outlook when an event poops up you have the option to reschedule however you want. Minutes, days whatever. It should really be something Apple does so apps don't have to add it.
Sigh... I'm taking on too many projects. :-) I haven't pursued this one because I just got a new bluetooth board to play with. I'm trying to make a generic compact bluetooth based switch (controlled by my iPhone) mostly for LED strips and such. I now have 10-15 computers in my desk drawer, Raspberry PI, BeagleBone, several Arduinos and about 10 Bluetooth boards. Who'da thunk.
dgelessus last edited by
@JonB, it wouldn't be that difficult to implement a snooze system like you suggested. Maybe write a helper method to schedule the main notification as well as a few delayed "snooze reminders" afterwards. Store all notification dicts for the notification group in a file. The notifications' action URLs would launch a script that reads that file and cancels all still outstanding snooze notifications and executes the main action.
@zencuke, that must be one huge desk drawer you have there O_O
@dgelessus. Yes as I wrote that, I was thinking of implementations.... However in the past there were issues with deleting notifications. Not sure if that was solved in 1.5. The issue was that the notification time returned by
notification.get_scheduled()didn't match the value required to delete it. I suppose a helper function that saves notifications to a file would work.
I went ahead and implemented a reminder module which is an enhancement of the notification module, allowing recurring notifications.
You provide a uid, or by default it generates a random uid. The uid identifies a single reminder, which may have multiple underlying notifications tagged to it.
When a reminders time is hit, it will continue to send notifications at a specified interval and total number. Once a notification is responded to -- either tapping the notification or being in pythonista when the notification lands -- the action is run, and all other notifications using that uid are cancelled. It is possible to delete reminders by uid, or find the next fire date for a given uid. Also you can grab a dict containing the uids as keys.
Turns out there was no need for any local storage, as this could get out of sync anyway with system notifications, so I just use the first two args in the action url to capture the uid and script name.
techteej last edited by
I get a list index out of range when I run this on line 76.
I think Ole is working on a reminders module for the next update.
ccc last edited by
@techteej, You need to provide at least two command line arguements (tap and hold the run button for an extra second) to run this script.
Actually, the intended method is to import the module, like you would
notifications, I guess that wasn't clear. The script part of this only is called when the reminder time happens-it cancels the extra "snooze" notifications, the dispatches the specified action.
import reminder reminder.reminder('time to eat cake ', delay=60, action='Zen')
You would set the other parameters if the action script wants sys.argv set, or to customize the timing, etc.
TutorialDoctor last edited by
I did a little with notifications in Editorial:
I am glad to know about badges though, and will be exploring further to see what is possible.
Doesn't reminders have a url scheme?
Also, how do you remove the badge?
And as a tip, if IOS reminders doesn't have a scheme for setting reminders, you could use an app that does.