I've searched the internet and couldn't find any solution to this. Then I've came up with a solution, but I am not sure if it is elegant. I'll post my own solution as well.
Basically what I want to do is to check if application is running when notification is clicked, not when notification comes (I already know how to do the latter). The difference is that, a notification can come when app is running but user can click on it later when app is not running. So, I need to check if app is running when notification is clicked.
How to do that?