How can I make an automation that triggers when my iPhone connects/disconnects from wifi

For the standard WiFi disconnect detection to work you need a way to contact your HA installation, when you are not on your home WiFi, like VPN, portforwarding or NabuCasa subscription.

No you don’t.

Yeah, you do.

The reply was for the previous post about the WiFi detection in the companion app and when that one detects you are offline, then you can not use the WiFi connection to report it, so you need another way to make a connection between the companion app and the HA server.