'Check if element is focused in Appium

How do I check if an element is focused in Appium? The advice for selenium seems to be to use:

element.equals(driver.switchTo().activeElement());

However this does not work using the appium mac2 driver as it appears that it's not possible to compare two elements for equality in appium:



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source