Check when the application is open in App Shortcuts

I'm writing an application with App Shortcuts support. My task is to write a command that will check whether a certain application is open and runs the command. For example:

  • The user installed a command through my application that responds to the Instagram application
  • The user goes to Instagram
  • My team is starting

Question: Is it possible to organize this?

Check when the application is open in App Shortcuts
 
 
Q