How to enter text in multiple text fields of a UIAlert with Appium for iOS native app in simulator in java

I have a native iOS app in which on clicking login the Username and password shows up in an alert.

I am unable to enter values in the Username and password and get an element not found exception.

If i switch to the alert I am able to get the text of alert using getText() , able to dismiss the alert but when I do alert.sendKeys() I am able to enter values only in username as it has focus. I am unable to switch to the password text field to enter value in it.

Any suggestions are most welcome