Forum Archive

notification.get_scheduled() gives an error

cvp

notification.get_scheduled() gives an error "name message is not defined".

Checking notification.py shows that the get_schedule def uses "message" but I don't see any declaration.

Using notification.app.scheduledLocalNotifications() is ok.

More, if I print my notifications, I see their "fire date", "URL" but not their "message". Strange!

import notification
#print(notification.get_scheduled())
scheduled = notification.app.scheduledLocalNotifications()
for each in scheduled:
    print(each.alertBody()) # shows the message

Thanks to a guru to explain please 😇

JonB

looks like a bug
https://github.com/omz/Pythonista-Issues/issues/21

In the meantime, you could copy notification.py and add the missing n. in the line below to get_scheduled

    info = {'message': n.message, 'fire_date': n.since1970, 'action_url': n.action_url, 'sound_name': n.sound_name}
cvp

Thanks a lot

Before Pythonista 3, I had used this get_scheduled without problem but if you check its source code in "standard library 2.7", the same error exists, it's strange.

JonB

In previous versions, notification was based on c code _notification module. Several modules have been switched over to objc_util based approaches.

cvp

One more time, thanks for your explanation