If the plane was at cruise altitude it wouldn't be possible to get a regular cell signal. As others have noted T-Mobile now has a partnership with Gogo. Probably just using iMessage or some other third party app that looks like texting.
You should be able to receive a cell signal until you reach around 4,000 feet AGL (above ground level). Nothing really scientific to back this up other than what I find when I go flying in my Cessna.