The Swiss rail company, SBB, has something called EasyRide in the SBB Android app. You hop on some form of transit, turn it on, and then turn it off again at the end of your journey. Then it figures out the most cost-effective ticket that would cover your trip and bills you for it (e.g. to your credit card).
I assume this works with trains in and around Basel, but does it also work with other forms of public transit in Basel? Can I use it in trams and busses?