getSelectedDocument returns undefined when sketch app is not focused 
I'm working on a plugin which has an event triggered from outside of the sketch app - the action is not done in sketch. 
I'm using getSelectedDocument api and it returns undefined whenever the sketch app is not focused - notice that the document is open.

Any suggestion / workaround to solve this issue?
Thanks!