How to run the same test cases in both android and ios

I want to run the same test cases in both android and ios. How to detect platform using appium and run the cases in both platform in a framework?. Any body knows please give the sample code for it…

I can be wrong, but the device id are must be described in capability. You can try to configure your project in such a way that when the test starts, several threads are started, to which the device id are transferred.
Something like this can be organized using a testng.

Any other way other than this?

If u automatically identify devise id, u can get devise version
Like ‘driver.getCapability(“platformVersion”)’
And use if-else construction, but I’m not sure what is that the best way