ERROR running Appium command: Cannot call method 'send' of null

I’m getting the following error

ERROR running Appium command: Cannot call method ‘send’ of null
while running my selelnium test on iPhones. The same works on Android. What could be the potential issue? any help is appreciated.

The code that throws the error is :

public static boolean focusWindowByHandle(int inWindowIndex) { boolean blResult = false; try { Object[] arrWindowHandles = GenericKeyword.driver.getWindowHandles().toArray(); if (inWindowIndex <= arrWindowHandles.length - 1) { String strWindowHandle = GenericKeyword.driver.getWindowHandles().toArray()[inWindowIndex].toString(); GenericKeyword.driver.switchTo().window(strWindowHandle); blResult = true;