Please do check and see if it's kennel cough..It's really important to rule this out. b/c like was mentioned before, it can turn into pneumonia which is really scary...The hacking usually happens at night too from what I've read, but this is also the case with asthma...
The only reason I mentioned if you had purchased anything new is because that happened with my yorkie earlier this year. He had a severe allergic reaction to a new blanket that I had purchased, and I had not washed it yet. He was hacking up foamy white stuff and wheezing at one point. Took him into the vet and figured out what was wrong..Shortly after we got rid of the blanket, he was all better