I've been doing this for years with some of my own personal projects like https://github.com/CamHenlin/imessageclient, https://github.com/CamHenlin/iMessageWebClient, and https://github.com/CamHenlin/imessagebot and some others - one thing that I'll note is that in my experience, Apple is pretty aggressive and somewhat arbitrary at banning accounts from accessing iMessages if they get on to the service from a VM - even if your usage is normal, personal iMessaging. I was trying out using VMWare and virtualbox specifically. In fact, I've been accidentally successful at getting my computer and home network banned from Apple services by accessing iMessages via VM. I strongly recommend running these types of services on bare metal Macs although ymmv.