How to use full Android/IOSDriver in a generic way

I would like to instantiate the driver generically so when an Android tests is run it creates an AndroidDriver and same for IOS.

The problem is that AppiumDriver does not provide some functionality of those classes (for instance, context methods). So, how can I accomplish that without having to cast the AppiumDriver?

https://discuss.appium.io/t/switch-between-android-driver-and-ios-driver-in-a-single-test-appium/