Forum Archive

Notifications and callback to myself

mcfetz

Hi all,

Isn't it possible to call my python script from a notification schedule with a callback url or is there a bug in the app?

This currently doesn't work:

test.py

# coding: utf-8
import notification

notification.schedule('test', 5, 'default', 'pythonista://test.py?action=run')

The script should send my a notification after 5 seconds. After accepting the notification the script should start again automatically.

Daniel

JonB

This worked fine for me, though I printed something in test.py first so it was obvious that it was running. one quirk: if pythonista is already open, you won't get a notification popup, it will just run. Try switching to another app while you wait, and bump up the delay a tad.

If you are running a script already, you will simply lose the notification.

mcfetz

Hi Jon.

I only get one notification. Do you really get multiple notifications (with a 5-sec delay after clearing the notification)?

JonB

yes. here is the exact test.py i used. note this must be in the main Documents folder

# coding: utf-8
import notification
print 'hi'
notification.schedule('hello',5,action_url='pythonista://test.py?action=run')
JonB

Also... don't "clear" the notification, tap it.

If you leave pythonista open, it will just keep printing hi.

mcfetz

Strange. Doesn't work.

I used your code and did:
- start the script test.py
- leave pythonista (went to the homescreen)
- don't lock the screen
- wait for the notification
- accept the notification
- pythonista is opened
- I see the "console" screen
- the script DOESN'T started again automatically :-(

JonB

ios version and device?
if you just open the pythonista link in safari, does it open and run?

mcfetz

iPhone 6s Plus running iOS 9.2
Pythonista 2.0

The link works in safari. The script runs automatically.

wnMark

This works fine on my iphone6 and iPad Air1.
But on iPad Pro with identical program I get an error "...no attribute shedule".

On all these devices I running Beta 201001
Does someone have an hint?

A second question. The reminder is not able to send a reminder to another iOS device with same Pythonista installed?

omz

@wnMark

But on iPad Pro with identical program I get an error "...no attribute shedule".

Maybe you introduced a typo somehow? It should be schedule, not shedule.

A second question. The reminder is not able to send a reminder to another iOS device with same Pythonista installed?

No, the notification module is just for timers etc. on the same device. You can use the reminders module to create reminders (optionally with notifications) that can be synced via iCloud.

wnMark

@omz thank you for your reply.
Okay, typo here in the text, but not in the program.:

import notification
notification.schedule('Hi guys!',10)

omz

@wnMark Just a guess: Have you perhaps created a script of your own, named notification.py on the iPad Pro? That would "shadow" the built-in module.

wnMark

@omz
Lessons Learned!

You're a mastermind!