We already have hack mountain including a bunch of stuff that is not even documented on SE. The trouble with answers there is they are hacky and often break between iOS releases.
It is possible more hacks can get this to magically detect this, I am not sure. But we can not afford to compromise standard software keyboard behavior by issuing random scroll events to fish for this.
Get that this is frustrating, but Apple ought to give us a correct viewport height somehow. Recommend you raise that with apple, I already did, got no answer.