How to manage multiple Hubs in the same location upon SmartApp installation?

Does anyone have some template code to use in a SmartApp to allow the Hub it needs to be installed on to be selected at install time? At present in my SmartApp I do:
def hub = location.hubs[0]
This obviously doesn’t work well now that I have multiple SmartThings Hubs (my original UK V2 Hub and some new AU Wifi Hubs) in the same location.

This SmartApp I’m talking about is at: