added page visibility check for notifications