What technology/protocol is used in iMessage app to show that user at other end is typing?
I know how it's done in a recent version of iMessage/Messages, but can't comment on other applications since there are many ways to do this.

The iMessage protocol allows an out-of-band "last message ID" to be tracked by Apple's servers for each conversation ID. This is separate from the end-to-end communication between parties. The "..." appears when the client application notices that the ID of the last message it has received is NOT the same as the conversation's last message ID according to Apple's servers.

APNS is not used for this unless it's a very recent development.

If, at some later point, the other party/parties stop preparing a new message, the ID held by Apple's servers will revert to the last message sent. Once the client app sees that the ID's match again, the "..." will disappear.

Another point: This will ONLY happen with "blue bubbles", since SMS does not provide a side channel for communication with the central authority (i.e. Apple's servers)