Unfortunately, the only way to get a keyboard to show, is during a user initiated event. This is something I've been fighting with myself as of late.
Below, ilumin has a good solution, but it's not the only one. Basically, from what I've found, as long as your are performing your .focus() function call inside of a user event (such as mouseup, or any of the touch events [which is probably preferred for a touch device]), then you shouldn't have a problem.
To an extent I understand why Apple made this limitation, but at the same time, it has made my work very challenging.